Mast Kalandar

bandar's colander of random jamun aur aam

Wed, 13 Sep 2006

< IISER Mathematics Courses for 2006 | · | Universities vs Polytechnics >

Editing PDF forms


Tags: , , , [link] [comments (0)] [raw]

"Real" PDF forms are quite common nowadays. How does one edit them with a "real" editor like vi (OK also emacs :-) )?

"pdftk" (PDF ToolKit) to the rescue.

Suppose that "form.pdf" is your PDF form.

  1. Extract the form information:

    pdftk form.pdf generate_fdf output form.fdf
    
    
  2. This only gets the text fields to get an idea of all the fields do:

    pdftk form.pdf dump_data_fields output form.fields
    
    
  3. Sometimes the field names are cryptic. It helps to also view the form.

    xpdf form.pdf
    
    

    or

    pdftotext -layout form.pdf; less form.txt
    
    

    (if you insist on text-mode)

  4. You can now edit the file form.fdf and fill in the fields marked with the string '%%EOF'.

  5. Once you have edited form.fdf you can generate the filled in form with:

    pdftk form.fdf fill_form form.fdf output filled.pdf
    
    

    or

    pdftk form.fdf fill_form form.fdf output filled.pdf flatten
    
    

    to get a non-editable pdf.

Some additional hints

  1. If your form.fdf file contains no '%%EOF' strings then you are out of luck---it means your PDF form is only a printable form and cannot be filled on the computer (but see the other hint about "flpsed").

  2. Checkboxes/buttons will not appear in the fdf file. You can use form.fields to find out what these fields are called and introduce entries in the fdf file as (here replace FN by the field name)

    <</V (Yes) /T (FN) >> 
    
    

    or

    <</V (Off) /T (FN) >> 
    
    
  3. It helps to have three windows open. One for editing, one for viewing the form.fields and one for viewing the filled pdf file.

  4. You may also want to periodically update the filling of the form to see whether the filling works.

Remarks

Clearly this is crying for someone to write a nice interface---why don't I you ask? I will ... but don't hold your breath.

You can skip all of this and use Adobe's Distiller, but most readers should be able to guess why I don't want to use that!


Name
E-mail (will not be displayed)
OpenID (required)
Simple HTML and wiki markup are allowed.

Archives

< September 2006 >
SuMoTuWeThFrSa
      1 2
3 4 5 6 7 8 9
10111213141516
17181920212223
24252627282930

2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000, 1999, 1997, 1995,