Whereas PDFs are typically considered pretty secure recordsdata, there’s quite a bit you are able to do with them on each Linux and different techniques. This consists of merging, splitting, rotating, breaking into single pages, encrypting and decrypting, making use of watermarks, compressing and uncompressing, and even repairing. The pdftk command does all this and extra.
The identify “pdftk” stands for “PDF software package,” and the command is surprisingly straightforward to make use of and does an excellent job of manipulating PDFs. For instance, to drag separate recordsdata right into a single PDF file, you’ll use a command like this:
$ pdftk pg1.pdf pg2.pdf pg3.pdf pg4.pdf pg5.pdf cat output OneDoc.pdf
That OneDoc.pdf file will include all 5 of the paperwork proven and the command will run in a matter of seconds. Notice that the cat choice directs the recordsdata to be joined collectively and the output choice specifies the identify of the brand new file.
You may also pull choose pages from a PDF to create a separate PDF file. For instance, in the event you wished to create a brand new PDF with solely pages 1, 2, 3, and 5 of the doc created above, you can do that:
$ pdftk OneDoc.pdf cat 1-Three 5 output 4pgs.pdf
If, then again, you wished pages 1, 3, 4, and 5, we would use this syntax as an alternative:
$ pdftk OneDoc.pdf cat 1 3-end output 4pgs.pdf
You might have the choice of specifying all particular person pages or utilizing web page ranges as proven within the examples above.
This subsequent command will create a collated doc from one which incorporates the odd pages (1, 3, and so forth.) and one which incorporates the even pages (2, 4, and so forth.):
$ pdftk A=odd.pdf B=even.pdf shuffle A B output collated.pdf
Discover that the shuffle choice make this collation doable and dictates the order by which the paperwork are used. Notice additionally: Whereas the odd/even pages instance would possibly counsel in any other case, you aren’t restricted to utilizing solely two enter recordsdata.
If you wish to create an encrypted PDF that may solely be opened by a recipient who is aware of the password, you can use a command like this one:
$ pdftk prep.pdf output report.pdf user_pw AsK4n0thingGeTn0thing
The choices present for 40 (encrypt_40bit) and 128 (encrypt_128bit) bit encryption. The 128 bit encryption is utilized by default.
You may also break a PDF file into particular person pages utilizing the burst choice:
$ pdftk allpgs.pdf burst $ ls -ltr *.pdf | tail -5 -rw-rw-r-- 1 shs shs 22933 Aug 8 08:18 pg_0001.pdf -rw-rw-r-- 1 shs shs 23773 Aug 8 08:18 pg_0002.pdf -rw-rw-r-- 1 shs shs 23260 Aug 8 08:18 pg_0003.pdf -rw-rw-r-- 1 shs shs 23435 Aug 8 08:18 pg_0004.pdf -rw-rw-r-- 1 shs shs 23136 Aug 8 08:18 pg_0005.pdf
The pdftk command makes pulling collectively, tearing aside, rebuilding and encrypting PDF recordsdata surprisingly straightforward. To be taught extra about its many choices, I try the examples web page from PDF Labs.