Create a PNG image from PDF

This event handler shows one approach of creating a PNG file from the generated pdf. It requires Anoto Live™ forms 3.x or greater.

<?php  // File: MyHandlers.php  class MyHandlers {    function addEventHandlers(RequestContext $ctx)   {     $ctx->addEventHandler(RendererEvent::PDF, $this, "onGeneratedPDF");   }    /**   * Create a PNG file from the PDF. Save it as a unique name in /tmp/   */   function onGeneratedPDF(RendererEvent $event)   {     $document = $event->document;     $pageNumber = 0;      $documentPNGRenderer = new PNGCutOutRenderer($document, $event->file, $pageNumber);     $documentPNG = uniqid("/tmp/document_") . ".png";     $documentPNGRenderer->render($documentPNG);      g_Log("Saved document " . $document->id . " image to " . $documentPNG);   } } ?>

Still need help? Contact Us Contact Us