Reputation: 211
I've been reading that there is a way to create/reference a .FDF file (used for merging data with a PDF form) that has an embedded URL to the original PDF to be filled in it, and a specifically crafted URL can be sent to the browser that will load Acrobat or related programs that will merge the FDF data with the PDF.
Presumably something like:
http://host/path/original.pdf#FDF=http://host/path/data.fdf
But I can't get that to work. Perhaps the path to the original PDF can be embedded within the .FDF file? I've heard there is something called an /F key that can be used. Can anyone give me an example of it's use, and if there is a special MIME format that is needed to have the browser recognize the file/merge, what would it be?
Here's an example of an FDF file - where do I put the original PDF url?
%FDF-1.2
%▒▒▒▒
1 0 obj
<</FDF<</F(Stand Alone EE.pdf)/Fields[
<</T(date)/V(07/11/2018)>>
<</T(uname)/V(Jennifer Smith)>>
<</T(pctbefore)/V(35)>>
<</T(aftfee)/V(40)>>
<</T(newclient)/V(Yes)>>
<</T(current_dateplus90days)/V(10/11/2018)>>
<</T(im_url)/V(http://internal_usl_for_something_else)>>
]/ID[<A3715E58793D9B5B9A48E8B2E0E057FF><BCE39B7672548444B7E6606F1B14E048>]/UF(Stand Alone EE.pdf)>>/Type/Catalog>>
endobj
trailer
<</Root 1 0 R>>
%%EOF
I have kind of given up on the .fdf format since apparently a newer version, .xfdf is available, but if either way can work, it would be great.
I have also tried this with the XFDF format as documented here: https://forums.adobe.com/thread/425699
The problem I've run into with the XFDF version is, when I click on the .xfdf it wants to save the file locally. I checked to make sure the mime type is set in the web server and it is. But if I save the .fdf and click on it, it opens up Acrobat, which then tries to open a document in Firefox with the same URL, which then prompts me if I want to open the document in Acrobat and it keeps spawning a circle of windows in Mozilla. Any idea what's wrong?
Here's a sample .fdf
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<f href="http://myhost/sample.pdf" />
<fields>
<field name="date"><value>07/11/2018</value></field>
<field name="atty"><value>Jennifer Smith</value></field>
<field name="typeofclaim"><value>Automobile Collision</value></field>
</fields>
</xfdf>
Anybody see anything wrong in the composition? What mime.type issues could I be having? My server is set to recognize .xfdf as "application/vnd.adobe.xfdf"
I set up a shell script to output the mime-type "application/vnd.adobe.xfdf", and then dump the content of the fxdf file above. The browser recognizes it as an Adobe app and I can open it with Acrobat, but then I get this error:
Xml parsing error: xml processing instruction not at start of external entity (error code 17) line 2 of file xxxxx.xfdf
Any idea what the error could be in the xml file? The parser says it's correct. Is it ok to terminate lines with \n?
Upvotes: 0
Views: 814
Reputation: 211
One problem I found with the field parsing is that it's very picky about the content of the form data if it's not encapsulated in some kind of structure (i.e. CDATA) that says "leave as is", so if you have a data form field, for example, that has unbalanced parenthesis, this can cause bizarre errors.
One of my fixes was to fully-validate the form field data. And make sure things like for every open parenthesis, there were closed parenthesis. This at least fixed one of the errors.
the .XFDF format here works:
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<f href="http://myhost/sample.pdf" />
<fields>
<field name="date"><value>07/11/2018</value></field>
<field name="atty"><value>Jennifer Smith</value></field>
<field name="typeofclaim"><value>Automobile Collision</value></field>
</fields>
</xfdf>
Upvotes: 0