How to create an e-Mail PDF Survey Form

From Scribus Wiki
Revision as of 08:13, 7 October 2009 by Mhanski (talk | contribs) (added pdf form toc)
Jump to navigation Jump to search
This article is part of the HOWTOs series.
Installation Usage PDF issues Imposition Other

Introduction

  1. Your first PDF form with Scribus
  2. How to create an e-Mail PDF Survey Form
  3. Your second PDF form with Scribus
  4. Enhance PDF forms with JavaScript

How often have you ever been emailed a PDF form that you have been told to print it, fill it in with a pen and then fax or post it back to the sender?

….and you thought to yourself, “Why don’t they just send me a PDF form that I can quickly type in the information and email it back.”

With Scribus you can create electronic PDF forms that can do exactly this. In the Scribus Wiki article “Your first PDF form with Scribus” you are shown how to create a sample PDF form and if you tried it, you will have an idea of what is involved.

The demonstration form however uses an online server which is complicated and expensive to setup.

A far simpler way is to use e-mails to exchange the data and the form can be easily modified to change the way the data is transferred. The setup of the Submit Button is all that needs to be changed. Instead of the data being sent as HTML to a web address, the mailto:” command is used. By using the mailto:” command, Adobe Acrobat Reader automatically attaches data in a FDF file to an email. This command works with most mail clients used in Windows and Linux. You can test your system by clicking on mailto:”.

FDF is short for Forms Data Format and they are basically text files that contain data from the PDF form. Not quite HTML, but a similar cousin. The form's field names and data are stored within a tag set. Characters between tags are irrelevant and don't appear anywhere within the displayed PDF file.

Adobe Acrobat Reader can open a FDF file but requires the original PDF form to do so. If you double click on a FDF file, Reader requests the location of the PDF form. Once linked up with the PDF form location, the PDF form opens with the FDF data in the fields. FDF files are a fraction of the size of the complete PDF form.


Creating a e-Mail PDF form

Scribussurvey.JPG


In the document “Your first PDF form with Scribus” you are shown how to create a PDF form to submit data to a server. A copy of the example file can be downloaded from a link on that page.

You can easily modify the example form to e-mail the data. Open the Scribus version of the document with Scribus. Right click your mouse on the “Submit” Button (Blue Rectangle). A menu pops up and select PDF Options –> Field Properties

Next select the Action Tab –> choose Submit Form and enter “mailto:” with your email address. Do not tick the Submit data as HTML.


Submit.JPG

Click OK. Now save your document as a PDF and view it with Adobe Acrobat Reader.

Testing your PDF form

Enter some data on the form and click the SUBMIT Button. By answering the prompts and security questions correctly, your email client should create an email with a FDF attachment to the address you specified. Something like the image below.

Email.JPG


Notice the difference in the file size between the FDF and PDF.


How to use FDF files

There are two options that I can think of -

1. Dump the data back into the form and print it, or

2. Extract the data into a spreadsheet or database


While Adobe would prefer you to purchase the full version of Acrobat, you can still do a lot with the free Scribus and Acrobat Reader software.

As the data in the FDF file is text, it is easily accessible by using a script or macro to extract the data contained in it. If you Save a FDF file from a e-mail (this is the only way to get one out of Reader) and open it in a text editor, you will the field names and your data with a whole lot of other characters.

If you use the example, you will see amongst other words and characters, the following words

Country Komentarz Miasto Name No Street Submit Telefon Zip

You will notice that this order is different to the PDF form. The fields are in alphabetical order. If you want your fields in the same order as on the PDF form, then you will need to name the fields in alphabetical order.

For example-

AName BStreet CNo DZip EMiasto FCountry GTelefon HKomentarz Submit


An example of a script to process FDF files into MS Excel
Links are BROKEN

openfdf.zip contains a MS Excel spreadsheet with a macro that allows you to extract data from FDF files. The macro is heavily commented to show what each line of code does.

For those without Excel who would like to have the script, openfdf.txt is the macro script in a text file. The macro code should be easily converted for use in other applications.


An example of code to process FDF files into MS Access

FDFdataImport.mdb contains a MS Access file with functions that allows you to extract data from FDF files. The functions are heavily commented to show what each line of code does.

There are two functions:-


CreateTable

This module displays creates an dialog box that lets the user specify the drive, directory, and the name of a FDF file to open. The data fields are extracted and a table called "tblFDFImport" is created with the appropriate field names.

The table can be manually adjusted to change the field types and sizes. The default field type is Text with a size of 200 characters.


DoAdobeImport

This module displays creates an dialog box that lets the user specify the drive, directory, and the name of a FDF file to open. The data is extracted into the table called "tblFDFImport".


Possible Uses for this System

Club membership applications / database

Client information database

Electronic Survey forms

Electronic examinations