FDFMerge and FDFMerge Lite Automation

In this chapter…

…we give a brief overview of CGI scripts and outline how you can use them to build applications that incorporate FDFMerge Lite and FDFMerge.

FDFMerge Lite or FDFMerge and CGI Scripts Together

If you are using FDFMerge Lite or FDFMerge to process information taken from a web server, you will find that you will rarely run FDFMerge Lite or FDFMerge from the command line. In order to incorporate FDFMerge Lite or FDFMerge into the operation of your web server you can use CGI scripts to provide a world wide web interface. CGI stands for Common Gateway Interface, and allows a web server and browser to interact. When a user clicks a web link, the CGI script associated with the link runs.

To create CGI scripts you can use any programming language that can call a command-line driven application. Some of the more popular languages include Visual Basic, Perl, ASP, Java, and C.

Sample Scripts

We make sample ASP, Perl, Java, PHP, and Visual Basic scripts available for you to review at our web site. The scripts are written for FDFMerge and can be found on our Sample Scripts webpage.

How the sample script might work

The following steps briefly summarize how a sample script works:

  1. A customer fills out an HTML form and submits it. A PDF form version of the HTML form exists on the server. As an alternative, you could use a PDF form that submits the export format of HTML form (URL encoded).
  2. The CGI script parses the form data and creates the FDF file with the field names and values the customer submitted.
  3. The CGI script calls FDFMerge Lite or FDFMerge.
  4. FDFMerge Lite or FDFMerge runs with the -o flag and makes a unique output file when it merges the form data and the PDF form document.
  5. The CGI script renames the merged file by appending the system time to the name to make it unique. For more information about this step, see below.
  6. The CGI script opens up the new merged PDF document.

Sample FDFMerge Lite or FDFMerge script

Diagram showing form.pdf + data.fdf = newform.pdf ouput as specifed by -o. Then CGI script renames file by appending system time to become newform102533.pdf.

Generating a unique filename for the completed form

Because the output filename is the same each time the CGI script runs, the script needs to rename the file so it won’t be overwritten. The current sample script appends the system time to the completed form name.

As an alternative to appending the time to your form name, you can have your CGI generate incrementing numbers instead. Each time the script runs, the number can be incremented by 1 and appended to the filename.

Using FDFMerge Lite or FDFMerge as a Database Solution

You can use FDFMerge Lite or FDFMerge to allow customers to retrieve and update information in a database. For example, a customer of a bank might want to visit her bank’s website to change her mailing address and access balances for several accounts.

  1. The customer fills out and submits a form that requests specific information. The request will require authorization in the form of an account number and password.
  2. A CGI script finds and extracts the requested information from the bank’s database and saves it to an FDF file.
  3. The CGI script runs FDFMerge Lite or FDFMerge to merge the data with a PDF form and returns the completed form to the customer’s browser.
  4. The customer views the completed form, makes the desired changes, and submits the updated information.
  5. The script can then update the database with the new information the customer has submitted.