0

I have some xfdf data as shown here and i need to fill an editable pdf in PHP. Can anyone give me a solution ?

<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<fields>
<field name="first_name">
<value>tismon</value>
</field>
<field name="last_name">
<value>varghese</value>
</field>
</fields>
<ids original="dbd3aadc6b6b85761ca83030e0558363" modified="1362548354" />
<f href="unlocked.pdf" />
</xfdf>
tis mon
  • 91
  • 2
  • 4

2 Answers2

3
  1. Download pdftk
  2. In case you need to know how to create fdf file through PHP

$fdf='<?xml version="1.0" encoding="UTF-8"?> <xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"> <fields> <field name="first_name"> <value>tismon</value> </field> <field name="last_name"> <value>varghese</value> </field> </fields> <ids original="dbd3aadc6b6b85761ca83030e0558363" modified="1362548354" /> <f href="unlocked.pdf" /> </xfdf>'; file_put_contents("file_name.fdf", $fdf);

3.Fill FDF to PDF

passthru("pdftk fillablePDF.pdf fill_form file_name.fdf output output.pdf flatten");

or you do this

exec("$root/resources\PDFtk\bin\pdftk fillablePDF.pdf fill_form   file_name.fdf output output.pdf flatten 2>&1");

Note: to make the file output fillable, you just ignore "flatten" in both cases: exec("$root/resources\PDFtk\bin\pdftk fillablePDF.pdf fill_form file_name.fdf output output.pdf 2>&1");

Eme
  • 71
  • 5
0

I've been trying to find a good answer for this as well, and this is the best I've found so far. Seems to work well.

Merge FDF data into a PDF file using PHP

Community
  • 1
  • 1
john.w
  • 323
  • 4
  • 13