3
votes

first let me say I searched a while before creating this request. Just to be sure :).

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

However, what my need is:

  1. A Backend where you can create/read/update/delete some sets of data (Which is not the problem).
  2. If any data in the backend was changed, a PDF gets written. This pdf has a static header and footer. In the middle part however, there is a dynamic form with all data fields from the backend (so if I create a Field named "Field 1", there should be a text-field on the created pdf also).
  3. Some parts of the fields need to trigger events, i.e. if I change "Select Box 1" to "Option 2", it should change a headline to a predefined text.
  4. The form fields need validation, so they must be filled out before printing the pdf (see 5.)
  5. There should be 2 Buttons, Reset (to reset the form to the defaults) and Print (Which should print the pdf in its current filled out state).

I know this is possible to do via Acrobat directly, but as I need to integrate it into a php based application I must create this form and its data via php.

I have searched on google for this, but did not find any proof that this will work in any of the popular PHP PDF-generators (I searched for Zend_PDF, DomPDF, TCPDF - which has at least support for forms but does not state if there are any possibilities for validation and XPDF).

I could also live with a command line interface if that would be the way to go (like generating a HTML-Page with JS for the validation from my PHP and rendering it to PDF via Tool x).

Is there anyone who has done something similar?

1

1 Answers

0
votes

I haven't implemented it yet, but I was faced with a very similar problem trying to enhance a running webapp (php+smarty) in order to give it the possibility of outputing pdfs (based on templates, which I believe would achieve your goals). After trying a few tools, we got to http://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp

Hope it helps!