I currently have a project there are a number of forms that are processed and stored in the DB. Upon successful completion an admin is notified by email with the contents of that form submission.
The problem is for one of these forms i need it to look exactly like the mail order version which I have in PDF format.
So I have two basic options:
- Figure out all the coordinates of the “field” i need to write to, and then overlay my drawn text at those coordinates
- Turn the pdf into a pdf form using Acrobat Pro’s form wizard and then set the field values programmatically
Option 1 i know is doable. I’ve done similar things before. The problem is the form is pretty complex and there are A LOT of coordinates to figure out… Moreover, there is a lot of trial and error to this process.
Option 2 seems like it would be easier so long as i can access the fields through iteration or name/id and just set the values.
So my question is, does Zend_Pdf support the manipulation of PDF form fields? I dont see anything in the API other than Submit and Reset form actions that would denote it supports this.
Additionally, if there are other OO F/OSS PDF libraries that would support option 2 i would be interested in hearing about them as well as any alternative approaches.
Sorry this is a bit late but thought this may be useful…
If you have access to add extra components to your server then you can use PDF Labs PDF Tooklit (pdftk) library – it is a command line utility but can obviously be accessed by system/exec/passthru commands in PHP. You can see pdftk info here: http://www.pdflabs.com/docs/pdftk-man-page/ PDFTK will allow you to merge PDFs, add background PDFs and fill form fields within a PDF (plus loads more) – see the fill_form switch.
If you can add pdftk to your server then you can also use Andrew Heiss’s pdftk-php class to make it easier to update the form fields in your pdf from the info pulled from your DB – you can see more info at: https://github.com/andrewheiss/pdftk-php/
One last comment – if you are ever wanting to create PDFs on the fly directly from HTML then by far the best solution is WKHTML2PDF – http://code.google.com/p/wkhtmltopdf/ – it basically works like a PDF screenshot of any HTML screen (a little more complex than that but you get the idea).
As you can probably tell I have just been working on a very similar problem and have gone through soooo many headaches to get a working solution.