Pdftk notes

From raju

combine multiple files into a single pdf

combine two files

    pdftk file1.pdf file2.pdf cat output combined.pdf
    

combine N files

    pdftk file1.pdf file2.pdf ... fileN.pdf cat output combined.pdf
    

Wildcards can also be used

    pdftk *.pdf cat output combined.pdf
    

dummy


Grab the first two pages in a pdf and reverse the order

pdftk A=inverted.pdf cat A2 A1 output corrected.pdf


To extract all the odd pages of a pdf file

pdftk A=all_pages.pdf cat A1-endodd output oddpages.pdf

Tested using

% pdftk --version

pdftk 2.02 a Handy Tool for Manipulating PDF Documents
Copyright (c) 2003-13 Steward and Lee, LLC - Please Visit: www.pdftk.com
This is free software; see the source code for copying conditions. There is
NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


The filenames should use absolute paths instead of '~'. For example

% pdftk A=~/books/thinkpython.pdf cat A44 output indentation.pdf

fails with

Error: Unable to find file.
Error: Failed to open PDF file: 
   ~/books/thinkpython.pdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.

but the command below succeeds.

% pdftk A=/home/rajulocal/books/thinkpython.pdf cat A44 output indentation.pdf

Tested using

% pdftk --version

pdftk 2.02 a Handy Tool for Manipulating PDF Documents
Copyright (c) 2003-13 Steward and Lee, LLC - Please Visit: www.pdftk.com
This is free software; see the source code for copying conditions. There is
NO warranty, not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.