1PDFTK(1)                    General Commands Manual                   PDFTK(1)
2
3
4

NAME

6       pdftk - A handy tool for manipulating PDF
7

SYNOPSIS

9       pdftk <input PDF files | - | PROMPT>
10            [input_pw <input PDF owner passwords | PROMPT>]
11            [<operation> <operation arguments>]
12            [output <output filename | - | PROMPT>]
13            [encrypt_40bit | encrypt_128bit]
14            [allow <permissions>]
15            [owner_pw <owner password | PROMPT>]
16            [user_pw <user password | PROMPT>]
17            [flatten] [compress | uncompress]
18            [keep_first_id | keep_final_id] [drop_xfa]
19            [verbose] [dont_ask | do_ask]
20       Where:
21            <operation> may be empty, or:
22            [cat | attach_files | unpack_files | burst |
23             fill_form | background | stamp | generate_fdf
24             dump_data | dump_data_fields | update_info]
25
26       For Complete Help: pdftk --help
27

DESCRIPTION

29       If PDF is electronic paper, then pdftk is an electronic staple-remover,
30       hole-punch, binder, secret-decoder-ring, and X-Ray-glasses.  Pdftk is a
31       simple tool for doing everyday things with PDF documents.  Use it to:
32
33       * Merge PDF Documents
34       * Split PDF Pages into a New Document
35       * Rotate PDF Documents or Pages
36       * Decrypt Input as Necessary (Password Required)
37       * Encrypt Output as Desired
38       * Fill PDF Forms with X/FDF Data and/or Flatten Forms
39       * Generate FDF Data Stencil from PDF Forms
40       * Apply a Background Watermark or a Foreground Stamp
41       * Report PDF Metrics such as Metadata and Bookmarks
42       * Update PDF Metadata
43       * Attach Files to PDF Pages or the PDF Document
44       * Unpack PDF Attachments
45       * Burst a PDF Document into Single Pages
46       * Uncompress and Re-Compress Page Streams
47       * Repair Corrupted PDF (Where Possible)
48

OPTIONS

50       A summary of options is included below.
51
52       --help, -h
53              Show summary of options.
54
55       <input PDF files | - | PROMPT>
56              A list of the input PDF files. If you plan to combine these PDFs
57              (without using handles) then list files in the  order  you  want
58              them combined.  Use - to pass a single PDF into pdftk via stdin.
59              Input files can be associated with handles, where a handle is  a
60              single, upper-case letter:
61
62              <input PDF handle>=<input PDF filename>
63
64              Handles  are often omitted.  They are useful when specifying PDF
65              passwords or page ranges, later.
66
67              For example: A=input1.pdf B=input2.pdf
68
69       [input_pw <input PDF owner passwords | PROMPT>]
70              Input PDF owner passwords, if  necessary,  are  associated  with
71              files by using their handles:
72
73              <input PDF handle>=<input PDF file owner password>
74
75              If  handles  are  not  given, then passwords are associated with
76              input files by order.
77
78              Most pdftk features require that encrypted input PDF are  accom‐
79              panied  by  the  ~owner~ password. If the input PDF has no owner
80              password, then the user password must be given, instead.  If the
81              input PDF has no passwords, then no password should be given.
82
83              When  running  in do_ask mode, pdftk will prompt you for a pass‐
84              word if the supplied password is incorrect or none was given.
85
86       [<operation> <operation arguments>]
87              If this optional argument is omitted, then pdftk runs  in  'fil‐
88              ter'  mode.   Filter mode takes only one PDF input and creates a
89              new PDF after applying all of the output options,  like  encryp‐
90              tion and compression.
91
92              Available   operations  are:  cat,  attach_files,  unpack_files,
93              burst,     fill_form,     background,     stamp,      dump_data,
94              dump_data_fields,  generate_fdf,  update_info.  Some  operations
95              takes additional arguments, described below.
96
97          cat [<page ranges>]
98                 Catenates pages from input PDFs to create a  new  PDF.   Page
99                 order  in  the new PDF is specified by the order of the given
100                 page ranges.  Page ranges are described like this:
101
102                 <input  PDF  handle>[<begin  page  number>[-<end  page   num‐
103                 ber>[<qualifier>]]][<page rotation>]
104
105                 Where  the  handle identifies one of the input PDF files, and
106                 the beginning and ending page numbers  are  one-based  refer‐
107                 ences to pages in the PDF file, and the qualifier can be even
108                 or odd, and the page rotation can be N, S, E, W, L, R, or D.
109
110                 If the handle is omitted from the page range, then the  pages
111                 are taken from the first input PDF.
112
113                 The even qualifier causes pdftk to use only the even-numbered
114                 PDF pages, so 1-6even yields pages 2, 4 and 6 in that  order.
115                 6-1even yields pages 6, 4 and 2 in that order.
116
117                 The odd qualifier works similarly to the even.
118
119                 The page rotation setting can cause pdftk to rotate pages and
120                 documents.  Each option sets the page rotation as follows (in
121                 degrees):  N:  0,  E:  90, S: 180, W: 270, L: -90, R: +90, D:
122                 +180. L, R, and D make relative adjustments to a page's rota‐
123                 tion.
124
125                 If  no  arguments  are passed to cat, then pdftk combines all
126                 input PDFs in the order they were given to create the output.
127
128                 NOTES:
129                 * <end page number> may be less than <begin page number>.
130                 * The keyword end may be used to reference the final page  of
131                   a document instead of a page number.
132                 * Reference a single page by omitting the ending page number.
133                 *  The  handle  may be used alone to represent the entire PDF
134                   document, e.g., B1-end is the same as B.
135
136                 Page Range Examples w/o Handles:
137                 1-endE - rotate entire document 90 degrees
138                 5 11 20
139                 5-25oddW - take odd pages in range, rotate 90 degrees
140                 6-1
141
142                 Page Range Examples Using Handles:
143                 Say A=in1.pdf B=in2.pdf, then:
144                 A1-21
145                 Bend-1odd
146                 A72
147                 A1-21 Beven A72
148                 AW - rotate entire document 90 degrees
149                 B
150                 A2-30evenL - take the even pages from the  range,  remove  90
151                 degrees from each page's rotation
152                 A A
153                 AevenW AoddE
154                 AW BW BD
155          attach_files <attachment filenames | PROMPT> [to_page <page number |
156          PROMPT>]
157                 Packs arbitrary files into a PDF using PDF's file  attachment
158                 features.  More  than  one  attachment  may  be  listed after
159                 attach_files. Attachments are added  at  the  document  level
160                 unless  the  optional  to_page option is given, in which case
161                 the files are attached to the given page  number  (the  first
162                 page is 1, the final page is end). For example:
163
164                 pdftk  in.pdf  attach_files table1.html table2.html to_page 6
165                 output out.pdf
166
167          unpack_files
168                 Copies all of the attachments from the  input  PDF  into  the
169                 current  folder or to an output directory given after output.
170                 For example:
171
172                 pdftk report.pdf unpack_files output ~/atts/
173
174                 or, interactively:
175
176                 pdftk report.pdf unpack_files output PROMPT
177
178          burst  Splits a single, input PDF document  into  individual  pages.
179                 Also creates a report named doc_data.txt which is the same as
180                 the output from dump_data.  If the output section is omitted,
181                 then  PDF  pages  are  named: pg_%04d.pdf, e.g.: pg_0001.pdf,
182                 pg_0002.pdf, etc.  To name these  pages  yourself,  supply  a
183                 printf-styled  format  string  via  the  output section.  For
184                 example, if you want pages named:  page_01.pdf,  page_02.pdf,
185                 etc.,  pass output page_%02d.pdf to pdftk.  Encryption can be
186                 applied to the output by appending  output  options  such  as
187                 owner_pw, e.g.:
188
189                 pdftk in.pdf burst owner_pw foopass
190
191          fill_form <FDF data filename | XFDF data filename | - | PROMPT>
192                 Fills  the  single input PDF's form fields with the data from
193                 an FDF file, XFDF file or  stdin.  Enter  the  data  filename
194                 after  fill_form,  or  use - to pass the data via stdin, like
195                 so:
196
197                 pdftk form.pdf fill_form data.fdf output form.filled.pdf
198
199                 After filling a form,  the  form  fields  remain  interactive
200                 unless you also use the flatten output option. flatten merges
201                 the form fields with the  PDF  pages.  You  can  use  flatten
202                 alone, too, but only on a single PDF:
203
204                 pdftk form.pdf fill_form data.fdf output out.pdf flatten
205
206                 or:
207
208                 pdftk form.filled.pdf output out.pdf flatten
209
210                 If  the  input  FDF file includes Rich Text formatted data in
211                 addition to plain text, then the Rich  Text  data  is  packed
212                 into  the  form fields as well as the plain text.  Pdftk also
213                 sets a flag that cues Acrobat/Reader to  generate  new  field
214                 appearances  based on the Rich Text data.  That way, when the
215                 user opens the PDF, the viewer  will  create  the  Rich  Text
216                 fields  on  the spot.  If the user's PDF viewer does not sup‐
217                 port Rich Text, then the user will see the  plain  text  data
218                 instead.   If  you  flatten  this  form  before Acrobat has a
219                 chance to create (and save) new field appearances,  then  the
220                 plain text field data is what you'll see.
221
222          background <background PDF filename | - | PROMPT>
223                 Applies  a  PDF watermark to the background of a single input
224                 PDF.  Pass the background  PDF's  filename  after  background
225                 like so:
226
227                 pdftk in.pdf background back.pdf output out.pdf
228
229                 Pdftk  uses  only  the first page from the background PDF and
230                 applies it to every page of the  input  PDF.   This  page  is
231                 scaled  and rotated as needed to fit the input page.  You can
232                 use - to pass a background PDF into pdftk via stdin.
233
234                 If the input PDF does not have a transparent background (such
235                 as  a  PDF  created from page scans) then the resulting back‐
236                 ground won't be visible -- use the stamp feature instead.
237
238          stamp <stamp PDF filename | - | PROMPT>
239                 This behaves just like the background feature except it over‐
240                 lays  the  stamp  PDF page on top of the input PDF document's
241                 pages.  This works best if the stamp PDF page has a transpar‐
242                 ent background.
243
244          dump_data
245                 Reads  a  single,  input PDF file and reports various statis‐
246                 tics, metadata, bookmarks (a/k/a outlines), and  page  labels
247                 to  the  given  output filename or (if no output is given) to
248                 stdout.  Does not create a new PDF.
249
250          dump_data_fields
251                 Reads a single, input PDF file and reports form field statis‐
252                 tics  to the given output filename or (if no output is given)
253                 to stdout.  Does not create a new PDF.
254
255          generate_fdf
256                 Reads a single, input PDF file and generates a FDF file suit‐
257                 able  for fill_form out of it to the given output filename or
258                 (if no output is given) to stdout.  Does  not  create  a  new
259                 PDF.
260
261          update_info <info data filename | - | PROMPT>
262                 Changes the metadata stored in a single PDF's Info dictionary
263                 to match the input data file. The input data  file  uses  the
264                 same  syntax  as  the  output  from  dump_data. This does not
265                 change the metadata stored in the PDF's XMP stream, if it has
266                 one. For example:
267
268                 pdftk in.pdf update_info in.info output out.pdf
269
270       [output <output filename | - | PROMPT>]
271              The  output  PDF filename may not be set to the name of an input
272              filename. Use - to output to stdout.  When using  the  dump_data
273              operation,  use  output to set the name of the output data file.
274              When using the unpack_files operation, use  output  to  set  the
275              name  of  an  output directory.  When using the burst operation,
276              you can use output to control the resulting PDF  page  filenames
277              (described above).
278
279       [encrypt_40bit | encrypt_128bit]
280              If  an  output  PDF  user or owner password is given, output PDF
281              encryption strength defaults to 128 bits.  This can be  overrid‐
282              den by specifying encrypt_40bit.
283
284       [allow <permissions>]
285              Permissions  are applied to the output PDF only if an encryption
286              strength is specified or an owner or user password is given.  If
287              permissions  are  not  specified,  they default to 'none,' which
288              means all of the following features are disabled.
289
290              The permissions section may include one or more of the following
291              features:
292
293              Printing
294                     Top Quality Printing
295
296              DegradedPrinting
297                     Lower Quality Printing
298
299              ModifyContents
300                     Also allows Assembly
301
302              Assembly
303
304              CopyContents
305                     Also allows ScreenReaders
306
307              ScreenReaders
308
309              ModifyAnnotations
310                     Also allows FillIn
311
312              FillIn
313
314              AllFeatures
315                     Allows  the  user  to  perform  all of the above, and top
316                     quality printing.
317
318       [owner_pw <owner password | PROMPT>]
319
320       [user_pw <user password | PROMPT>]
321              If an encryption strength is given but  no  passwords  are  sup‐
322              plied,  then  the  owner  and user passwords remain empty, which
323              means that the resulting PDF may  be  opened  and  its  security
324              parameters altered by anybody.
325
326       [compress | uncompress]
327              These  are  only useful when you want to edit PDF code in a text
328              editor like vim or emacs.  Remove PDF page stream compression by
329              applying  the  uncompress  filter.  Use  the  compress filter to
330              restore compression.
331
332       [flatten]
333              Use this option to merge an input PDF's interactive form  fields
334              (and their data) with the PDF's pages. Only one input PDF may be
335              given. Sometimes used with the fill_form operation.
336
337       [keep_first_id | keep_final_id]
338              When combining pages  from  multiple  PDFs,  use  one  of  these
339              options  to  copy the document ID from either the first or final
340              input document into the new output PDF. Otherwise pdftk  creates
341              a  new  document  ID  for  the  output PDF. When no operation is
342              given, pdftk always uses the ID from the (single) input PDF.
343
344       [drop_xfa]
345              If your input PDF is a form created using  Acrobat  7  or  Adobe
346              Designer,  then  it  probably has XFA data.  Filling such a form
347              using pdftk yields a PDF with data  that  fails  to  display  in
348              Acrobat  7  (and  6?).  The workaround solution is to remove the
349              form's XFA data, either before you fill the form using pdftk  or
350              at the time you fill the form. Using this option causes pdftk to
351              omit the XFA data from the output PDF form.
352
353              This option is only useful when running pdftk on a single  input
354              PDF.   When  assembling  a PDF from multiple inputs using pdftk,
355              any XFA data in the input is automatically omitted.
356
357       [verbose]
358              By default, pdftk runs quietly. Append verbose to the end and it
359              will speak up.
360
361       [dont_ask | do_ask]
362              Depending on the compile-time settings (see ASK_ABOUT_WARNINGS),
363              pdftk might prompt you for further input when  it  encounters  a
364              problem,  such as a bad password. Override this default behavior
365              by adding dont_ask (so pdftk won't ask you what to do) or do_ask
366              (so pdftk will ask you what to do).
367
368              When  running in dont_ask mode, pdftk will over-write files with
369              its output without notice.
370

EXAMPLES

372
373
374       Decrypt a PDF
375         pdftk secured.pdf input_pw foopass output unsecured.pdf
376
377       Encrypt a PDF using 128-bit strength (the default), withhold  all  per‐
378       missions (the default)
379         pdftk 1.pdf output 1.128.pdf owner_pw foopass
380
381       Same  as  above, except password 'baz' must also be used to open output
382       PDF
383         pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz
384
385       Same as above, except printing is allowed (once the PDF is open)
386         pdftk 1.pdf output 1.128.pdf owner_pw foo user_pw baz allow printing
387
388       Join in1.pdf and in2.pdf into a new PDF, out1.pdf
389         pdftk in1.pdf in2.pdf cat output out1.pdf
390         or (using handles):
391         pdftk A=in1.pdf B=in2.pdf cat A B output out1.pdf
392         or (using wildcards):
393         pdftk *.pdf cat output combined.pdf
394
395       Remove 'page 13' from in1.pdf to create out1.pdf
396         pdftk in.pdf cat 1-12 14-end output out1.pdf
397         or:
398         pdftk A=in1.pdf cat A1-12 A14-end output out1.pdf
399
400       Apply 40-bit  encryption  to  output,  revoking  all  permissions  (the
401       default). Set the owner PW to 'foopass'.
402         pdftk 1.pdf 2.pdf cat output 3.pdf encrypt_40bit owner_pw foopass
403
404       Join  two files, one of which requires the password 'foopass'. The out‐
405       put is not encrypted.
406         pdftk A=secured.pdf 2.pdf input_pw A=foopass cat output 3.pdf
407
408       Uncompress PDF page streams for editing the PDF in a text editor (e.g.,
409       vim, emacs)
410         pdftk doc.pdf output doc.unc.pdf uncompress
411
412       Repair a PDF's corrupted XREF table and stream lengths, if possible
413         pdftk broken.pdf output fixed.pdf
414
415       Burst   a  single  PDF  document  into  pages  and  dump  its  data  to
416       doc_data.txt
417         pdftk in.pdf burst
418
419       Burst a single PDF document into  encrypted  pages.  Allow  low-quality
420       printing
421         pdftk in.pdf burst owner_pw foopass allow DegradedPrinting
422
423       Write a report on PDF document metadata and bookmarks to report.txt
424         pdftk in.pdf dump_data output report.txt
425
426       Rotate the first PDF page to 90 degrees clockwise
427         pdftk in.pdf cat 1E 2-end output out.pdf
428
429       Rotate an entire PDF document to 180 degrees
430         pdftk in.pdf cat 1-endS output out.pdf
431

NOTES

433       pdftk     uses    a    slightly    modified    iText    Java    library
434       (http://itextpdf.sourceforge.net/) to read and write  PDF.  The  author
435       compiled  this  Java library using GCJ (http://gcc.gnu.org) so it could
436       be linked with a front end written in C++.
437
438       The pdftk home page is http://www.accesspdf.com/pdftk/.
439

AUTHOR

441       Sid Steward (ssteward@accesspdf.com) maintains pdftk.
442
443
444
445                              September 18, 2006                      PDFTK(1)
Impressum