Reputation: 100
I have a PDF document which I am filling with dynamic content from a html form. Up until now it has only been text and checkboxes. However I now need to add an image into the PDF (the image is always changing).
Using the code at http://koivi.com/fill-pdf-form-fields/ I am creating creating a XFDF file, then simply running it and the data appears in the correct places.
How would I get this working so that I can also load in a dynamic image? I have read a couple places about creating a button but that hasn't seemed to work.
xfdf source;
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<fields>
<field name="first_name">
<value>John</value>
</field>
<field name="last_name">
<value>Doe</value>
</field>
<field name="somekindofimageplaceholder">
<value>data:image/png;base64,iVBORw0dfsfsdsdf...</value>
</field>
</fields>
<ids original="f87c5ab87f1666163abd9537ba917f11" modified="1404772492" />
<f href="mypdf.pdf" />
</xfdf>
Ideally I wanted to use a base64 string but this isn't a necessity. I looked over at the xfdf spec and there is a snapshot element which takes base64 strings for images but this is just for 3dviews..? http://partners.adobe.com/public/developer/en/xml/XFDF_Spec_3.0.pdf
Any help would be greatly appreciated. Cheers.
EDIT: I couldn't find a solution for doing this in pure XFDF. As a hacky work around I'm creating the PDF form with a XFDF file then merging it using PDFTK with another generated PDF which contains the image.
Upvotes: 3
Views: 2776