Reputation: 101
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
Reputation: 81
$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
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