Posted by: qwick | January 11, 2009

Filling PDF Forms in PHP – Vol 2

Pdftk

Using pdftk is a powerful way to produce PDF files.  This command line application is lightweight and fast.  It can be used for many things such as combining multiple PDF files, splitting pages into new documents, encryption, and attaching files.

How it Works

Using an FDF file created in the previous article, save this to the web server instead of outputing it to the client.  Then run the command line application providing the PDF form and the FDF file and flatten into a single output PDF.

Advantages

  • The unfilled PDF file does not have to be web accessible
  • The filled PDF form is provided to the client
  • Free
  • All programs support reading the resulting PDF files

Disadvantages

  • Not always easy to work with
  • May not be compatible with all PDF files (version 1.6 forms not working at the time of this post)
  • A C++ executable needs to be placed on the web server
  • The PDF form must be created in a way that has named fields

Implementation

Create a FDF file from the previous article and save it to the web server.  Have the PHP application run the following shell command on the web server (assuming pdftk can be run without a full path):

pdftk pdfform.pdf fill_form fdffile.fdf output outputpdf.pdf flatten

Pdftk can be obtained here:

http://www.pdftk.com/

Posted by: qwick | January 11, 2009

Filling PDF Forms in PHP

There are many ways to fill PDF files with data.  This article should help you decide which solution works best for you.  I will be adding many more options in the future.

FDF/XFDF

Using FDF/XFDF files is a clean and simple answer.  These small files provide the data values to a standard PDF form file.

How it Works

When you open the FDF file, the original PDF form is loaded with the values in the FDF file.  The original PDF file is downloaded from any web location.

Advantages

  • Very easy to implement
  • No third party libraries or applications required on the web server
  • Free
  • Filled out form files are small
  • Form data is stored separately from the PDF form making spelling mistakes easy to fix

Disadvantages

  • The original PDF must be web accessible
  • Some PDF programs may not support the FDF format
  • The PDF form must be created in a way that has named fields

Implementation

A great tutorial showing exactly how to produce FDF and XFDF files in native PHP code (no PECL extension or executable required)

http://koivi.com/fill-pdf-form-fields/

Posted by: qwick | January 11, 2009

Photoshop Image Slicing

Ever wanted to know how to slice a Photoshop website mock-up into web-friendly images?  This tutorial shows you how to quickly slice Photoshop files with ease:

http://www.tutorials007.com/from-photoshop-to-dreamweaver/

When working with web templates provided by designers, it is often necessary to slice the file into multiple smaller images.  This quick tutorial should help you turn that nicely crafted Photoshop page into a manageable set of web ready files.

Categories