Joining and splitting PDFs

2021-10-16 | aprates.dev

[1] Leia este post em português

If PDF is electronic paper, then pdftk is an electronic staple-remover, hole-punch, binder, secret-decoder-ring, and X-Ray-glasses. - man pages

Today I stumbled across a nice command-line utility available for Linux, Mac and Windows, namely PDF Tool Kit, packaged under codename pdftk for doing everyday things with PDF documents, two of which I experimented with: removing pages and merging files. Easy-peasy!

So, grab pdftk from your favorite package manager, or directly from one of the references noted bellow [2] [3], and let's get hands on by organizing those precious PDFs you have lying around :D

Removing Pages

…by selecting the pages you want to keep!

pdftk original.pdf cat 5 output result.pdf
pdftk original.pdf cat 6 3 4 output result.pdf
pdftk original.pdf cat 1-5 output result.pdf
pdftk original.pdf cat 2-end output result.pdf
pdftk original.pdf cat 1-6 even output result.pdf
pdftk original.pdf cat 1-6 odd output result.pdf

Merging Files

…by labeling like A B C
pdftk A='file1.pdf' B='file2.pdf' C='file3.pdf' cat A B C output result.pdf
You get the idea!

Power Hacks

It's a swiss army knife and can do a lot more, so maybe you want to check the man pdftk to unveil it's full powers.

References

[2] Original pdftk under GPL
[3] Java port of pdftk under GPL

See also

[4] Capsule Archives
[5] Capsule Home

Want more?

Comment on one of my posts, talk to me, say: hello@aprates.dev

[6] Subscribe to the Capsule's Feed
[7] Checkout the FatScript project on GitLab
[8] Checkout my projects on GitHub
[9] Checkout my projects on SourceHut

Join Geminispace

Gemini is a new Internet protocol introduced in 2019, as an alternative to http(s) or gopher, for lightweight text contents and better privacy.

Not sure how, but want to be part of the club? See:
[10] Gemini quick start guide

Already have a Gemini client?
[11] Navigate this capsule via Gemini


© aprates.dev, 2021-2023 - content on this site is licensed under
[12] Creative Commons BY-NC-SA 4.0 License
[13] Proudly built with GemPress
[14] Privacy Policy