pdftk

By Sachin
August 26, 2012

pdftk can be an excellent tool for manupilating PDFs if you know some handy commands

merge pages

suppose I have some PDF pages like

front.pdf, toc.pdf, auth_colo.pdf, part1.pdf, chap01.pdf,
chap02.pdf, part2.pdf, chap03.pdf, chap04.pdf, chap05.pdf,
part3.pdf, app_A.pdf, app_B.pdf, and, index.pdf

If I want to merge all the pdf’s into a single book(file), my command would be

pdftk front.pdf toc.pdf auth_colo.pdf part1.pdf chap01.pdf...index.pdf cat output my_full_book.pdf

this will create a pdf file in the same order specified. *.pdf may also work if I don’t care about page ordering. Remember that my_full_book.pdf is output file name and cat output are output flags.

removing a page

suppose I want to remove page number 3 then my command would be

pdftk my_full_book.pdf cat 1-2 4-end output full_book_with_page2-removed.pdf

in the above example, I skipped page number(s) which I want to remove, in this case, page-3. The above command means, I want pages to be included from 1 to 2, I don’t want page number 3, so skip it, then start from page 4 till the end.

the syntax goes like this

pdftk PDF_FILE cat FROM-TO FROM-end output NEW_PDF_FILE_NAME

rotating pages

If I want to rotate the first page at 90 degrees right, then

pdftk my_full_book.pdf cat 1R 2-end output page1_turned_right.pdf

in the same way if I want to rotate all odd pages from range 1 to 25 to 180 degrees, then

pdftk my_full_book.pdf cat 1-25oddD 26-end output odd_pages_down_book.pdf

Extract specific page(s)

pdftk lkn.pdf cat 4 5 output page4and5.pdf

pdftk lkn.pdf cat 9 output page9.pdf

Split pages as individual file

pdftk page4and5.pdf burst

Output file will be pg_0001.pdf, pg_0002.pdf

Reference

For more info on pdftk, visit its manual pages by typing

man pdftk