Fill PDF Documentation

Last modified: May 22, 2009 - 21:12

The Fill PDF module populates existing PDF forms with token-specified content

Installation

Install via sites/all/modules > Other > Fill PDF (depends on CCK & Tokens)

Setup

There are three steps to setting up a form with Fill PDF: (1) creating the webform (), (2) mapping the PDF to that webform, (3) using a URL to merge the two.

  1. To create the webform wherein users will enter data. Options:
  2. To map the webform to a PDF, do the following:
    1. Go to /admin/content/fillpdf
    2. Click the "Add PDF" tab
    3. Enter a title for this form, as well as either the PDF's URL or upload a PDF Note: Make sure the PDF document isn't encrypted. If it is encrypted and non copy-righted (typical of government PDFs), then try a decrypting tool like "Advanced PDF Password Recovery". If you upload an encrypted PDF, you will have empty PDFs when you attempt to download your submissions.
    4. Either click "Generate Fields From PDF" or "Add Field" to get fields into the form
    5. When added or editing fields, note the following:
      • "Label" is for your own use in identifying fields
      • "PDF Key" is the field-name from the original PDF Form (such as text_field_1) and is the piece that maps the form-field to the PDF field
      • "Value" is where you either enter static data to populate the field, or token-data to pull information form the users' forms. For example, if I created a CCK form with a text-field called field_first_name, then I would enter [field-field_first_name-raw] here. There is a list of tokens you can use at the bottom of that page.
  3. When you want to download your form to PDF, you need to navigate to a URL with the following format: http://example.com/fillpdf?fid=10&nid=10. nid is the node-id of the node whose content you want to populate your PDF. fid is the form-id of the mapping you previously created (you can obtain the fid from the URL when editing your form; it will look like: http://example.com/admin/content/fillpdf/form/{fid}). Since the URL needs nids, you'll likely need to dynamically-generate links (based on the logged-in user's recent submissions or whatever) to get the downloadables if you are using CCK. If clean URLs is not enabled, the URL will be in the format: http://example.com/?q=fillpdf&fid=10&nid=10

iText Servlet

This module depends on iText. Currently, I have a servlet installed on my home server that handles the iText functions via xmlrpc calls. If your PDF needs are intensive, you're likely to crash my server. Therefore, please deploy your own installment of http://ocdevel.com/sites/default/files/fillpdf_servlet.war via Apache Tomcat, then change line 9 of fillpdf.module to your servlet location.

I'd like to move away from servlets and get the PDF functionality into PHP, but there doesn't seem to be any PHP libraries that support PDF form-field parsing or XFDF-to-PFD merging and flattening, both which are necessary for this module to work. If anyone knows of a solution, please contact me. Otherwise, if you seriously want this functionality too, you might consider contacting one Pancho Sünderhauf who seems to be porting iText to PHP. Maybe a donation could stimulate his progress. In any case, I'll be keeping an eye on his progress, you can find his thread and contact info at http://www.nabble.com/PHP-port-in-the-works-td21609367.html.

URL of PDF if no Clean URLs

Liam Morland - April 22, 2009 - 14:27

If your site does not use Clean URLs, the URL of your filled PDF will be like this: http://www.example.com/?q=fillpdf&fid=10&nid=10

Tomcat - Deployment

Parkes Design - August 18, 2009 - 10:17

I can confirm that this works on Tomcat 5.5 and not 6.

 
 

Drupal is a registered trademark of Dries Buytaert.