Create pdfs with form fields with Open Source Software

Form data saving

There are several tools which allow the creation of PDF documents including fill in forms. But none of them can enable form data saving in Acrobat Reader. Only the original Adobe Acrobat Pro Writer allows to do this (“Advanced” -> “Enable Usage Rights in Adobe Reader…”)

There are other readers like "foxit" (Windows only) who allow to save the form data within the pdf.

Javascript

Writers

Openoffice can create pdfs with form fields, but does not allow javascript for calulations or validation.

Scribus can create pfds with forms an javascript.

PHP tcpdf can create pfds with forms an javascript.

Readers

The linux "evince" viewer does not support javascript.

Acrobat Reader 9 for Linux does support javascript.

Grafical Tools

Open Office

http://openoffice.blogs.com/forms_fromscratch.pdf

http://askubuntu.com/questions/166875/create-fillable-or-editable-fields-in-a-pdf

Scribus

http://documentation.scribus.net/index.php/PDF_Forms#Enhancing_PDF_Forms_With_JavaScript

http://wiki.scribus.net/canvas/How_to_enhance_your_PDF_forms_with_JavaScript

Programmatical Tools (PHP)

tcpdf

http://www.tcpdf.org

tcpdf can create pfds with forms and javascript.

DomPdf

http://code.google.com/p/dompdf/

http://pxd.me/dompdf/www/examples.php

Good html/css to pdf conversion, but no real pdf form fields support.

Reference

http://www.adobe.com/devnet/acrobat/javascript.html

Symfony Framework Setup

DomPdf

  • Save lib to lib/vendor/dompdf
  • Edit dompdf_config.inc.php
    • Comment font autoloader
      • if (DOMPDF_ENABLE_AUTOLOAD) {
          require_once(DOMPDF_INC_DIR . "/autoload.inc.php");
          //require_once(DOMPDF_LIB_DIR . "/php-font-lib/classes/font.cls.php");
        }
  • Example action
    •   public function executeStzPdf()
        {
          sfConfig::set('sf_web_debug', false);
         
          $html = $this->getPartial('stzPdf');
         
          require_once(sfConfig::get('sf_lib_dir') .
            '/vendor/dompdf/dompdf_config.inc.php');
         
          $dompdf = new DOMPDF();
          $dompdf->load_html($html);
          $dompdf->render();
         
          return $this->renderText($dompdf->stream("sample.pdf"));
        }

 

 

tcpdf

  • Save lib to lib/vendor/tcpdf
  • In a symfony action load the lib via
    •     require_once(sfConfig::get('sf_lib_dir') .
            '/vendor/tcpdf/tcpdf.php');