PDF, FDF, Local File and Command Line

2.1k Views Asked by At

Does anyone know if it is possible to open a PDF and feed in an FDF file via command line parameters from a local FDF and PDF file. There are several references around the web indicating that this can be done across http. I need to do it across the file system. The following example does not work but it could be because my parameters are not correct:

....\acrobat.exe c:\temp\myPDF.pdf#fdf=c:\temp\myFDF.fdf

2

There are 2 best solutions below

0
On

I upvoted & starred this question about 15 minutes ago, and then 5 minutes after that I found the solution.

The reason there's no information on how to import an FDF via command line is because it just isn't necessary. To understand why, we need to look into the FDF file itself.

The FDF file I've been working with contains one line with all of the fields & their values as <>. The line ends with;

/ID[<bit string><another bit string>]/UF(temp.pm.pdf)>>/Type/Catalog>>

The tl:dr we're interested in is that the filename be in the parentheses after UF. This is how the FDF and PDF are associated. I've replaced the field values and that filename value with tags wrapped in special characters. When my primary app writes out the FDF file, it populates with the value tags with the data that should go in the named fields in the PDF and it will associate the file with the PDF named in the /uf tag. I've only tested Adobe Reader XI and FoxIt Reader v60, but I can open the FDF with either reader and it will open the associated PDF and populate it. Get the filename wrong, and it will warn the me the file for which this FDF is associated can't be found, and ask if I'd like to find it. So there's even some recovery built in if you get the filename wrong!

FYI, the bit strings are a representation of the original contents of the PDF the first time it was saved and the 2nd bit string contains the most recently modified version. I don't really understand this, but it's necessary for it to be there.

Also, the fieldnames & values can go in any order so long as the correct syntax is maintained. This is handy, since your fields weren't necessarily added to the document in a logical order.

Even after I re-organized my FDF and replaced the example values with the tags I crunch later, that /ID[<><>] stuff needs to be there. Not exactly human readable and doesn't appear to be critical, but it will balk without it being there.

1
On

pdftk Example.pdf form_fill Example.fdf output ExampleFilled.pdf will do what you originally asked.