Thursday, May 22, 2008

pdftk

Need a commandline interface to take PDFs apart and put them back together again?

"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 command-line tool for doing everyday things with PDF documents."

Get pdftk here, for free.

Starter recipes.

To extract the first page from piece.pdf and save as first.pdf, type

pdftk piece.pdf cat 1-1 output first.pdf

To extract the last page from piece.pdf and save as last.pdf, type

pdftk piece.pdf cat end-end output last.pdf

To strip the first page from piece.pdf and resave with the same name, type

pdftk piece.pdf cat 2-end output piece.pdf

To merge cover.pdf, first.pdf, body.pdf, last.pdf and save as complete.pdf, type

pdftk cover.pdf first.pdf body.pdf last.pdf cat output complete.pdf

No comments: