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 briefly describes how combining these two elements creates solutions.
- Sample Scripts tells you where to find sample scripts and describes the algorithm for one of our demo scripts.
- Using FDFMerge Lite or FDFMerge as a Database Solution gives an outline of one way to incorporate FDFMerge Lite or FDFMerge in a database solution.
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.
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:
- 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).
- The CGI script parses the form data and creates the FDF file with the field names and values the customer submitted.
- The CGI script calls FDFMerge Lite or FDFMerge.
- 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.
- 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.
- The CGI script opens up the new merged PDF document.
Sample FDFMerge Lite or FDFMerge script
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.
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.
- 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.
- A CGI script finds and extracts the requested information from the bank’s database and saves it to an FDF file.
- 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.
- The customer views the completed form, makes the desired changes, and submits the updated information.
- The script can then update the database with the new information the customer has submitted.