PDFTK(1)                                                 PDFTK(1)



NAME
       pdftk - A handy tool for manipulating PDF

SYNOPSIS
       pdftk <input PDF files>
            [input_pw <input PDF owner passwords>]
            [<operation> <operation arguments>]
            [output <output filename>]
            [encrypt_40bit | encrypt_128bit]
            [allow <permissions>]
            [owner_pw <owner password>]
            [user_pw <user password>]
            [compress | uncompress] [flatten]
            [background <PDF filename>]
            [verbose] [dont_ask | do_ask]
       Where:
            <operation> may be empty, or:
            [cat | fill_form | dump_data | update_info |
             attach_file | unpack_files | burst]
       And:
            PDF filenames, passwords and permissions may be
            replaced with PROMPT, in order to prompt the user
            at run-time.
       For Complete Help:
            pdftk --help

DESCRIPTION
       If  PDF  is  electronic paper, then pdftk is an electronic
       staple-remover, hole-punch,  binder,  secret-decoder-ring,
       and  X-Ray-glasses.   Pdftk  is  a  simple  tool for doing
       everyday things with PDF documents.  Use it to:

       * Merge PDF Documents
       * Split PDF Pages into a New Document
       * Decrypt Input as Necessary (Password Required)
       * Encrypt Output as Desired
       * Fill PDF Forms with FDF Data and/or Flatten Forms
       * Apply a Background Watermark
       * Report on PDF Metrics, including Metadata and Bookmarks
       * Update PDF Metadata
       * Attach Files to PDF Pages or the PDF Document
       * Unpack PDF Attachments
       * Burst a PDF Document into Single Pages
       * Uncompress and Re-Compress Page Streams
       * Repair Corrupted PDF (Where Possible)

OPTIONS
       A summary of options is included below.

       --help, -h
              Show summary of options.

       <input PDF files>
              A list of the input PDF files. If you plan to  com-
              bine  these  PDFs (without using handles) then list
              files in the order you want them  combined.   Input
              files  can be associated with handles, where a han-
              dle is a single, upper-case letter:

              <input PDF handle>=<input PDF filename>

              Handles are often omitted.  They  are  useful  when
              specifying PDF passwords or page ranges, later.

              For example: A=input1.pdf B=input2.pdf

       [input_pw <input PDF owner passwords>]
              Input  PDF owner passwords, if necessary, are asso-
              ciated with files by using their handles:

              <input PDF handle>=<input PDF file owner password>

              If handles are not given, then passwords are  asso-
              ciated with input files by order.

              Most  pdftk  features  require that encrypted input
              PDF are accompanied by the ~owner~ password. If the
              input  PDF  has  no  owner  password, then the user
              password must be given, instead.  If the input  PDF
              has no passwords, then no password should be given.

              When running in do_ask mode, pdftk will prompt  you
              for  a  password if the supplied password is incor-
              rect or none was given.

       [<operation> <operation arguments>]
              If this optional argument is  omitted,  then  pdftk
              runs  in 'filter' mode.  Filter mode takes only one
              PDF input and creates a new PDF after applying  all
              of  the  output arguments, like encryption and com-
              pression.

              Available   operations   are:    cat,    fill_form,
              dump_data,  update_info, attach_file, unpack_files,
              burst. Some operations takes additional  arguments,
              described below.

          cat    Catenates  pages from input PDFs to create a new
                 PDF.  Page order in the new PDF is specified  by
                 the order of the given page ranges.  Page ranges
                 are described like this:

                 <input  PDF  handle>[<begin  page  number>[-<end
                 page number>[<qualifier>]]]

                 Where the handle identifies one of the input PDF
                 files, and the beginning and ending page numbers
                 are  one-based  references  to  pages in the PDF
                 file, and the qualifier can be even or odd.

                 If the handle is omitted from  the  page  range,
                 then  the  pages  are taken from the first input
                 PDF.

                 If no arguments are passed to  cat,  then  pdftk
                 combines  all  input PDFs in the order they were
                 given to create the output.

                 NOTES:
                 * <end page number> may be less than <begin page
                   number>.
                 *  The  keyword end may be used to reference the
                   final page of a document  instead  of  a  page
                   number.
                 * Reference a single page by omitting the ending
                   page number.
                 * The handle may be used alone to represent  the
                   entire  PDF document, e.g., B1-end is the same
                   as B.

                 Page range examples:
                 A1-21
                 Bend-1odd
                 A72
                 A1-21 Beven A72

          fill_form
                 Fills the single input PDF's  form  fields  with
                 the  data  from  an FDF file. Enter the FDF data
                 filename after fill_form, like so:

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

                 After  filling  a  form,  the form fields remain
                 interactive unless you also use the flatten out-
                 put  option. flatten merges the form fields with
                 the PDF pages. You can use flatten  alone,  too,
                 but only on a single PDF:

                 pdftk form.pdf fill_form data.fdf output out.pdf
                 flatten

                 or:

                 pdftk form.filled.pdf output out.pdf flatten

          dump_data
                 Reads a single, input PDF file and reports vari-
                 ous  statistics,  metadata,  and bookmarks (out-
                 lines) to the given output filename  or  (if  no
                 output  is  given) to stdout.  Does not create a
                 new PDF.

          update_info
                 Changes the metadata stored in  a  single  PDF's
                 Info  dictionary  to  match the input data file.
                 The input data file uses the same syntax as  the
                 output  from dump_data. This does not change the
                 metadata stored in the PDF's XMP stream,  if  it
                 has one. For example:

                 pdftk in.pdf update_info in.info output out.pdf

          attach_file
                 Packs  arbitrary  files  into  a PDF using PDF's
                 file attachment features. More than one  attach-
                 ment  may  be  listed after attach_file. Attach-
                 ments are added at the document level unless the
                 optional  to_page option is given, in which case
                 the files are attached to the given page  number
                 (the  first  page  is 1, the final page is end).
                 For example:

                 pdftk in.pdf attach_file table1.html table2.html
                 to_page 6 output out.pdf

          unpack_files
                 Copies all of the attachments from the input PDF
                 into the current folder or to an  output  direc-
                 tory given after output. For example:

                 pdftk     report.pdf     unpack_files     output
                 ~/atts/report/

          burst  Splits a single, input PDF document  into  indi-
                 vidual   pages.  Also  creates  a  report  named
                 doc_data.txt which is the  same  as  the  output
                 from dump_data.  The output section is not used.
                 Encryption can be applied  by  appending  output
                 arguments, like encrypt_128bit, e.g.:

                 pdftk     in.pdf    burst    owner_pw    foopass
                 encrypt_128bit

       [output <output filename>]
              The output PDF filename may not be set to the  name
              of  an  input  filename. Use - to output to stdout.
              When using the dump_data operation, use  output  to
              set  the  name  of the output data file. When using
              the unpack_files option, use output to set the name
              of an output directory.

       [encrypt_40bit | encrypt_128bit]
              If  an  output PDF user or owner password is given,
              output PDF  encryption  strength  defaults  to  128
              bits.    This   can  be  overridden  by  specifying
              encrypt_40bit.

       [allow <permissions>]
              Permissions are applied to the output PDF  only  if
              an  encryption strength is specified or an owner or
              user password is given.   If  permissions  are  not
              specified,  they default to 'none,' which means all
              of the following features are disabled.

              The permissions section may include one or more  of
              the following features:

              Printing
                     Top Quality Printing

              DegradedPrinting
                     Lower Quality Printing

              ModifyContents

              Assembly

              CopyContents

              ScreenReaders

              ModifyAnnotations

              FillIn

              AllFeatures
                     Allows the user to perform all of the above,
                     and top quality printing.

       [owner_pw <owner password>] [user_pw <user password>]
              If an encryption strength is given but no passwords
              are  supplied,  then  the  owner and user passwords
              remain empty, which means that  the  resulting  PDF
              may  be  opened and its security parameters altered
              by anybody.

       [compress | uncompress]
              These are only useful when you  want  to  edit  PDF
              code  in  a  text editor like vim or emacs.  Remove
              PDF page stream compression by applying the  uncom-
              press  filter.  Use  the compress filter to restore
              compression.

       [flatten]
              Use this option to merge an input PDF's interactive
              form  fields (and their data) with the PDF's pages.
              Only one input PDF may  be  given.  Sometimes  used
              with the fill_form operation.

       [background]
              Use  this  option to add a background to every page
              of the (single) input PDF. The background is  taken
              from  the  first  page of the PDF given after back-
              ground, e.g.:

              pdftk  invoice_data.pdf  output  invoice.pdf  back-
              ground invoice_form.pdf

       [verbose]
              By  default,  pdftk runs quietly. Append verbose to
              the end and it will speak up.

       [dont_ask | do_ask]
              Depending  on  the   compile-time   settings   (see
              ASK_ABOUT_WARNINGS),  pdftk  might  prompt  you for
              further input when it encounters a problem, such as
              a  bad  password. Override this default behavior by
              adding dont_ask (so pdftk won't ask you what to do)
              or do_ask (so pdftk will ask you what to do).

              When  running  in  dont_ask  mode, pdftk will over-
              write files with its output without notice.

EXAMPLES
       Decrypt a PDF
         pdftk secured.pdf input_pw foopass output unsecured.pdf

       Encrypt a PDF using 128-bit strength (the default),  with-
       hold all permissions (the default)
         pdftk 1.pdf output 1.128.pdf owner_pw foopass

       Same as above, except password 'baz' must also be used  to
       open output PDF
         pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz

       Same as above, except printing is allowed (once the PDF is
       open)
         pdftk 1.pdf output 1.128.pdf owner_pw  foo  user_pw  baz
         allow printing

       Join in1.pdf and in2.pdf into a new PDF, out1.pdf
         pdftk in1.pdf in2.pdf cat output out1.pdf
         or (using handles):
         pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
         or (using wildcards):
         pdftk *.pdf cat output combined.pdf

       Remove 'page 13' from in1.pdf to create out1.pdf
         pdftk in.pdf cat 1-12 14-end output out1.pdf
         or:
         pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf

       Apply  40-bit  encryption  to output, revoking all permis-
       sions (the default). Set the owner PW to 'foopass'.
         pdftk   1.pdf   2.pdf  cat  output  3.pdf  encrypt_40bit
         owner_pw foopass

       Join  two  files,  one  of  which  requires  the  password
       'foopass'. The output is not encrypted.
         pdftk A=secured.pdf 2.pdf input_pw A=foopass cat  output
         3.pdf

       Uncompress  PDF page streams for editing the PDF in a text
       editor (e.g., vim, emacs)
         pdftk doc.pdf output doc.unc.pdf uncompress

       Repair a PDF's corrupted XREF table and stream lengths, if
       possible
         pdftk broken.pdf output fixed.pdf

       Burst  a  single PDF document into pages and dump its data
       to doc_data.txt
         pdftk mydoc.pdf burst

       Burst  a  single  PDF document into encrypted pages. Allow
       low-quality printing
         pdftk  mydoc.pdf  burst owner_pw foopass allow Degraded-
         Printing

       Write a report on PDF document metadata and  bookmarks  to
       report.txt
         pdftk mydoc.pdf dump_data output report.txt

NOTES
       pdftk  uses  a  slightly  modified  iText   Java   library
       (http://itextpdf.sourceforge.net/)  to read and write PDF.
       The  author  compiled  this   Java   library   using   GCJ
       (http://gcc.gnu.org)  so  it  could be linked with a front
       end written in C++.

       The pdftk home page is http://www.accesspdf.com/pdftk/.

AUTHOR
       Sid Steward (ssteward@accespdf.com) maintains pdftk.



                         August 13, 2004                 PDFTK(1)
