Troubleshooters.Com and T.C Linux Library Present

Filling Out PDF Forms:
PDF->Gimp->PDF

Copyright (C) 2008 by Steve Litt, All rights reserved. Material provided as-is, use at your own risk. 



Contents
    
Other PDF Related Pages

Disclaimer

This page discusses filling out PDF forms by converting to .ppm, editing with Gimp, and back-converting. Doing this will remove all form properties from the PDF. It will also create a somewhat pixellated image, and might make the PDF file considerably larger. It's not at all appropriate for groupware.

DO NOT use the techniques on this page without fully verifying that the resulting PDF is what the recipient needs. I am not responsible for any damage or injury caused by your use of this page, or caused by errors and/or omissions in this page. If that's not acceptable to you, you may not use this web page. By using this web page, you are accepting this disclaimer.

Introduction

The preceding disclaimer not withstanding, I regularly use Gimp to fill out PDF forms for trademark and copyright applications, and other applications to government entities. Look at the alternative. I could download the PDF, print it, fill it out by hand, and scan it. Have you seen my handwriting!?

Fact is, it's very likely my handwritten application responses would be misread, causing huge problems. Oh, and if I bungle one field, I need to either cross it out and initial it, or start over with a brand new paper. No thanks!

Some folks recommend using a typewriter to fill out paper copies of PDF forms. That gets rid of the legibility problem, but not the problems if you make a mistake. And have you ever tried exactly lining up a typewriter to a line on a form? Yuck!

Some people recommend using Imagemagick's convert utility. Good luck with that -- pixelation city. Same with importing the PDF directly into Gimp. The original PDF's text, if small, will be barely legible.

Ubergeeks recommend using PDFTK to directly fill out the form, PDF style. Hey, I love PDFTK, but to use it this way you need to find all the fields, write a specially formatted file listing all the fields, and then running a rather complex PDFTK command. You know my problem with that? If I'm concentrating on making a trademark application suitable for the attorneys at the USPTO, I want my full attention on content, not on PDF creation.

In other words, I want Gimp!

So I use Gimp. The pdftoppm program converts the PDF to several ultra-high quality .ppm files (one per page). I put in my responses using Gimp. Then I print to Gimp's Adobe Acrobat printer, using print to file, and then use ps2pdf to convert it back to a PDF. That PDF file prints beautifully on my printer.

Converting PDF to PPM

The first step is to convert the PDF to a high quality .ppm file (actually a series of them). Let's say you just downloaded the Form TX copyright form from the copyright office website. You'll use the pdftoppm utility, whose command line syntax looks like this:
pdftoppm [options] PDF-file PPM-root
The PPM-root argument is a string, with no spaces, to serve as the common part of all the .ppm page files that will be created. In this case the only option we'll use is the -r option to specify a resolution of 300 dots per inch -- plenty to prevent major pixellation:
[slitt@mydesk junk2]$ pdftoppm -r 300 formtx.pdf mytx
Error: PDF version 1.6 -- xpdf supports version 1.5 (continuing anyway)
[slitt@mydesk junk2]$ ls -l mytx*
-rw-r--r-- 1 slitt slitt 25245017 May 29 11:52 mytx-000001.ppm
-rw-r--r-- 1 slitt slitt 25245017 May 29 11:52 mytx-000002.ppm
[slitt@mydesk junk2]$

Oh-oh, look at that error message! However, it then says "continuing anyway", and in fact creates the two .ppm files, one for each page of the original PDF file.

Ugh! Each .ppm file is 25MB in size. Each is over 100 times bigger than the original PDF. Don't worry, they will shrink again when you back-convert to PDF. They won't be as small as the original PDF, but they'll be tolerable.

How clean is the conversion? The original PDF's main text was a light 9 point font. The following graphic shows a section, portrayed in Gimp, at a 100% zoom (original size):
Converted ppm

As you can see, the .ppm file is ultra-clean, with no noticible pixellation. Now it's time to add your own information.

Filling Out The Form With Gimp

The first thing to do is open each .ppm file in Gimp, and save it as a .xcf file. Gimp's native format is .xcf, a format which keeps your layers intact.

Now go to each place where information should be typed, and use Gimp's text tool to type it in. Choose a common typeface whose font you can export (Times New Roman Bold or Arial Bold, for instance), and type it in a size readable to even poorly sighted people. Just because the original text was 9 point doesn't mean you can't make yours twice as big, assuming it fits in the allotted space. Also, remember that the original type size on paper has little to do with the size in Gimp. Experiment to get the right type size for information you type in.

Modern Gimp versions create a new layer for each piece of text you type in, so to go back and change text, you need to Dialogs->Layers and pick the right layer, then click the layer with the text tool (type t to access the text tool), and change the text. If all you need to do is move the text, you can choose the Move tool by typing m, and then click and move the text that needs moving, whether it's the current layer or not.

The following graphic shows the part of the file, after I added an X to indicate that it's not work for hire:
Converted XCF with input

Once you've made all changes on all xcf pages, using Gimp, it's time to turn it back into one or more PDF files...

Turning Each .xcf Into a PDF

By far the easiest way to do short PDF files is to turn each page into a separate PDF. There are a million ways to do this, but most shrink the page slightly, causing pixellation. The way you want to do it is this, from within Gimp:

  1. File->Print
  2. Click Export button
  3. Click Setup Printer button
  4. Choose Adobe, and then Postscript 2
  5. Click the File radio button, and then type in the desired page PDF name, which should end in .ps
  6. Click the Print button
  7. ps2pdf myfile.ps
  8. File myfile.pdf now contains the information in the filled out .xcf page file.
  9. Repeat for each page.


Turning All .xcf Pages Into a Single PDF

Please keep in mind that this PDF won't be a form any more. Nevertheless, for easy sending, you can turn all the pages into a single .pdf. For each .xcf page that will be in the file, do this:

  1. File->Print
  2. Click Export button
  3. Click Setup Printer button
  4. Choose Adobe, and then Postscript 2
  5. Click the File radio button, and then type /home/mydir/myfileN.ps, where N is the page number, zero-frontfilled to four digits.
  6. Click the Print button
You've just created a .ps file for each page. Now put them together with this command:
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=myfile.pdf -f myfile*.ps
That's it -- you've combined all the pages into one PDF file. The pages are in the right order because you named each page with a number that was zero-front-filled, so myfile00001.ps would sort before myfile00004.ps which would sort before myfile00011.ps.

Summary

Many government agencies have their forms as downloadable forms. Many of these forms are PDF forms that can be filled out with Adobe Acrobat or Adobe Acrobat Reader. However, Acrobat Reader cannot save for later use -- it must print immediately. To save for later use, one method I find handy is to convert the PDF into a series of page-long .ppm files, edit those as Gimp-native .xcf files in Gimp to put in the required information, then print the .xcf files to Gimps Adobe Postscript 2 printer device, printing to file. Those individual files can either be converted to individual PDF files using ps2pdf, or they can be combined into a single PDF file with the gs command.


Back to Troubleshooters.Com * Back to Linux Library