Create dynamic PDF (using form fields and interactive elements) from PHP

first let me say that I have been looking for a while before making this query. To be sure:).

I would like to create a dynamic PDF via PHP. There are many free classes (DomPDF, TCPDF, Zend_PDF, etc.) that can handle regular (static) PDF creation without any problems.

However, what I need:

  • A Backend where you can create / read / update / delete some datasets (which is not a problem).
  • If any data in the backend has been changed, the PDF will be written. This pdf has a static header and footer. However, there is a dynamic form in the middle with all the data fields from the backend (so if I create a field named "Field 1" there should also be a text field in the generated pdf).
  • Some parts of the fields need to trigger events, i.e. if I change "Select Box 1" to "Option 2" it should change the title to predefined text.
  • Form fields must be validated, so they must be filled in before printing in pdf format (see 5.)
  • There should be 2 buttons, Reset (before Reset the default form) and Print (which should print the PDF in its current filled state).

I know it can be done through Acrobat directly, but since I need to integrate it into a php application, I have to create this form and its data through php.

I searched on Google for this but found no evidence that this would work in any of the popular PHP PHP generators (I searched Zend_PDF, DomPDF, TCPDF) which at least supports forms, but not if there are any- or testability and XPDF).

I could live with a command line interface as well, if that were the case (for example, creating an HTML page with JS to validate from my PHP and rendering it to PDF using the x tool).

Is there anyone who has done something similar?

+3


source to share


1 answer


I haven't implemented it yet, but I ran into a very similar problem trying to improve a running webapp (php + smarty) to give it the ability to output pdfs (based on templates that I believe will achieve its goals). After trying several tools we got to http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp



Hope it helps!

0


source







All Articles