ZF-141: Possibility to replace placeholders in an existing PDF with form data


PDF standard offers several interactive features. One of them is interactive form processing (sometimes referred to as an AcroForm).

Forms are described by 8.6 section of PDF Reference V1.6

That would be good to have possibility to create PDF form and to fill it.


Changing fix version to 0.6.0.

Postponed to post-1.0 period

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

I needed this feature, and could not wait, so I added it myself to Zend_Pdf. Attached my unofficial implementation, for anyone who might find it useful.

Can be used to prepopulate Acroform form fields that already exist in a .pdf, like this:

$pdf = Zend_Pdf::load('input-file-containing-form.pdf'); $pdf->setTextField('name', 'Someone'); $pdf->setTextField('address', '1 Main Street'); $pdf->setTextField('city', 'Cyberspace'); $pdf->save('outputfile.pdf');

I just added an improved patch based on the one of Floris, which also implements a dummy hasTextField() method

Well, I just seem not to be allowed to post a patch on this ticket... It is available on demand.

I believe there is something incorrect here somewhere. When trying to use PDFTK to "flatten" the PDF form after filling it in, PDFTK generates a PDF without the form data. However, when creating a FDF file with PHP and filling in the PDF with PDFTK and THEN flattening the file, it works fine.

On a separate note, it would be nice if Zend_PDF could flatten a PDF. I hate having to mess with PDFTK.