Skip to main content

 

 

DealerTeam

Make Your FDF Beautiful

Goal

FDF stands for "Forms Data Format" and is a file format for representing form data and annotations that are contained in a PDF form.

The system generated FDF is functional though not pretty, making it less than ideal to work with. A text editor that supports regular expressions can be used to manipulate the FDF to achieve a more workable format. 

There are a couple steps you'll need to complete before jumping in to make your FDF beautiful. 

Preflight

First you'll need to prepare your environment by acquiring a quality text editor and generate the base FDF.

Download a Quality Text Editor

When doing any job you need the right tools. To upgrade your FDF according to this article you'll need a good text editor that supports regular expressions. Regular Expressions, commonly referred to as Regex, allow for pattern matching in text strings. In this case we can use Regex to identify the repeating pattern for each key/value pair and manipulate the form based upon that. 

We use and recommend Sublime Text at DealerTeam which is free to evaluate without continued use. While there is no defined syntax highlighting for FDF we find that within Sublime Text the Go highlighting works well.

Generate FDF

Create a Form record, upload the PDF form, and get the system generated FDF according to this article.

Get FDF Pairs on a Single Line

The system generated FDF is valuable because it automatically provides a key/value pair with the key populated for each field on the PDF form. Unfortunately, each of these pairs takes up four lines in the text editor. The lines consist of:

  1. Opening Chevrons: <<
  2. Value: /V ()
  3. Text Key: /T (Form Field Name)
  4. Closing Chevrons: >>

Step 1: Move Value to same line as opening chevrons

The next steps will replace the new-line characters ( \n) with double spaces. This step will bring the entire entry on to a single line.

Find the chevrons (<<) with a new-line character ( \n), followed by the value ( /V). Replace the new-line ( \n) with two spaces.

Follow the example provided.

Find: <<\n/V
Replace: <<../V 
helpNote_icon.gif When writing regular expressions into your text editor do not copy/paste. These expressions contain some characters, such as gray dots to represent spaces, that won't translate.

Step 2: Move Text Key to same line as closing chevrons

Find a closing parentheses followed by a new-line character and closing chevrons. Replace the new-line with two spaces.

Follow the example provided. 

Find: \)\n>>.
Replace: )..>>
helpNote_icon.gif Before executing this step be sure that all the closing chevrons have a space after, in particular check the last one which may have a closing bracket.

Step 3: Move Text Key and Value to same line

Find a new-line character followed by the text key and replace the new-line with two spaces.

Find: \n/T
Replace: ../T

Step 4: Switch the Text Key and the Value

It is most convenient when manipulating FDF data to have the text key first on the line. When assembled properly, the text keys will roughly match the same order of the fields on the PDF form. It also allows for quick access to the field even if the value includes a long formula.

Explanation of the matching is provided below, which outlines there are two capture groups.

  • The first capture group is the Value
  • The second capture group is the Text Key.

In the switch, we transpose the two capture groups to display the Text Key first.

Find: ^<<..(.+)..(\/T.+)..>>$
Replace: <<..\2..\1..>>

Regex Explanation
Created at https://regex101.com/r/qhtOJN/1

What's Next

Now you're ready to manipulate your FDF for ease of use and maintenance. With your FDF ready to go it's time to add value formulas and get your forms filling with data from DealerTeam. Check out the FDF Forms Uploading article for details.