Forms Data Format

From GNUpdf
Jump to: navigation, search

FDF or Forms Data Format is a format designed by Adobe. It separates a form (the fields and the presentation) from the data that fill in the form (the FDF data). The file extension is .fdf. It's described in ISO-3200, the PDF specification.

Applications:

  • you send a PDF that people fill in with the PDF reader, and they send back the data over the Internet (via POST to a web server like a classic web form, or to a mail address). Apparently proprietary PDF readers prevent the user from saving forms data, asking the user to print the forms instead (TODO: motivation?).
  • you have an existing PDF template, and you can merge it with .fdf data to produce a personalized PDF without having to generate it entirely using PDF generation

Here's a simple FDF file:

%FDF-1.2
%éééé
1 0 obj
<<
  /FDF <<
    /Fields 2 0 R
  >>
>>
endobj

2 0 obj
[
  <<
    /T (field1)
    /V (value1)
  >>
  <<
    /T (field2)
    /V (value2)
  >>
]
endobj

trailer
<<
/Root 1 0 R
>>
%%EOF

Note that FDF files are composed by PDF objects in the syntactic level, and they feature a trailer dictionary. This fact makes it possible to reuse a PDF implementation to read and generate FDF data. For instance, it is possible to use the object layer functions of the GNU PDF Library to read, write and manipulate FDF files.

There's an alternative representation called xfdf (.xfdf) which is based on XML (this is not to be confused by Mars, which is another Adobe format to represente whole PDF-like files based on XML, probably as a response to MS XPS). XFDF is referenced in ISO-32000 but is described separately, see the bottom of developer resources at adobe.com, more precisely xfdf_2.0.pdf.

Apparently Adobe introduced something newer called XFA (XML Forms Architecture) which doesn't seem standardized.


Tools

  • pdftk: can extract fdf data from a pdf, and fill-in a pdf forms from fdf data. License: GPLv2+
# generate blank .fdf file
pdftk example.pdf generate_fdf output out.fdf
# fill in the pdf with .fdf data (fill_form) and make fields uneditable (flatten)
pdftk form.pdf fill_form data.fdf output out.pdf flatten 
  • pdftk-php: used to present PDF forms (blank or filled with user data) through a web browser. Not a complete pdftk front-end, though, despite the name. License: mBSD
Personal tools
Namespaces

Variants
Actions
project
Tools