tis mon
tis mon

Reputation: 101

Fill pdf with xfdf data

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>

Upvotes: 1

Views: 4218

Answers (2)

Eme
Eme

Reputation: 81

  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");

Upvotes: 3

john.w
john.w

Reputation: 343

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

Upvotes: 0

Related Questions