PDF Toolkit
August 12 2017150 words, ~1 min. read
PDFtk is a simple yet effective tool for PDF.
- encrypt document
pdftk <input>.pdf output <encrypted>.pdf encrypt_128bit owner_pw <owner-password> user_pw <user-password>- decrypt encrypted document
pdftk <encrypted>.pdf input_pw <password> output <decrypted>.pdf- combine multiple documents
pdftk <one>.pdf <two>.pdf cat output <output>.pdf- insert blank page
- let's say if we have
1.pdfwith 3 pages,2.pdfwith 5 pages and we need to combine into a new file with a sequence of all the pages in1.pdf, a blank page and then the last two pages of2.pdf,
$ pdftk F=1.pdf S=2.pdf B=blank.pdf cat F1-end B S4-5 output result.pdf
$ # or
$ pdftk F=1.pdf S=2.pdf B=blank.pdf cat F B S4-5 output result.pdf
Note: To create blank.pdf, use ghostscript or imagemagick as shown below,
- Use
ps2pdffromghostscript
$ touch blank.ps
$ ps2pdf blank.ps blank.pdf
- Use
imagemagick
$ magick xc:none -page Letter blank.pdf
See also