4D Code Exchange is hosted by SSS 4 Computer Solutions, LLC.

SSS 4 Computer Solutions, LLC has been providing quality computer solutions for over 26 years

 

FDF Form Builder

This code has been used with 4D Client/Server and 4th Dimension Developer version 2003.7 and 2003.8r2 on both Mac OS X and Windows XP. The 4D code is simple enough that it should work with any version of 4D from at least 3.0 through 2004.

License

You are free to use and modify this code in any way you see fit. While I will assist where possible, I am not responsible for any existing or future bugs I do request that you send any updates to Dennis Little so that it may be incorporated into the code being distributed.

Purpose

Adobe thoughtfully provided a method to store data outside of a PDF document in an FDF (Form Data Format) file. After some research, I discovered that this file format is close enough to all text to create it directly from 4D. This is the same format Adobe Acrobat Professional and Standard use when exporting data using the "File/Form Data/Export Data from Form..." menu option.

Advantages

  1. One of the optional items in an FDF is a file location which will accept not only a local file but a web address. If someone else is in charge of creating and maintaining PDF's within your organization, you can access forms which they create.
  2. If your PDF forms change frequently (as is the case with some government forms), the FDF will still work as long as the previous field information are left alone. If they add a field, you can modify your code to insert the new values. If they modify the text of the form, it doesn't matter at all.
  3. Not all fields must be included in the FDF. If a field isn't included, it's simply left blank in the PDF. This is especially useful when first creating a complicated FDF.
  4. The FDF data is shown just as if you had typed it. This has the advantage that any features of the PDF (security, javascript, etc) are left completely intact in the original FDF.
  5. Because it's text only, the file size is very small. If you've ever created a PDF on a Mac with either the print function or the Preview application, you know these can be MUCH larger than needed.
  6. If all the data is in the FDF, the user doesn't need to save it so Acrobat Reader is all that's needed.

Disadvantages

  1. PDF's are similar in make-up to PostScript files. Both are case sensitive. If even one item is the wrong case, nothing will be displayed.
  2. In order to get the field names, you'll need a full version of Acrobat or some other tool which will let you get the field names.
  3. Checkboxes come in 2 flavors grouped and individual. Individual checkboxes will usually have a value of "Yes" or "Off". Grouped checkboxes are different in that each checkbox will have its own value. If you have problems with your FDF, look here first.

How I Use This Module

In my case, most of the data I need is stored in the database but not all. As a result, I have a button on an input form which calls a dialog to gather the remaining data before building the FDF. I then just call the main method as many times as needed in order to build FDF.

Resources

I found the following pages extremely useful in explaining the basic formatting.

Merging data with a PDF Form
Submit a PDF Form to Itself

Contents of Download

2 Methods -- PDF_BuildFDF & Forms_Build_1298
PDF_BuildFDF is the method used to build all FDF files.
Forms_Build_1298 is an example method showing the calls needed to build the file.

 

]