-- Leo's gemini proxy

-- Connecting to aprates.dev:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini

Joining and splitting PDFs

2021-10-16 | aprates.dev


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!


Keep only page 5:

pdftk original.pdf cat 5 output result.pdf

Keep pages 6 3 4 in this exact order:

pdftk original.pdf cat 6 3 4 output result.pdf

Keep first 5 pages:

pdftk original.pdf cat 1-5 output result.pdf

Keep the pages to the `end` excluding the first:

pdftk original.pdf cat 2-end output result.pdf

Keep `even` pages 2, 4 and 6:

pdftk original.pdf cat 1-6 even output result.pdf

Keep `odd` pages 1, 3 and 5:

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


Original pdftk under GPL

Java port of pdftk under GPL


See also


Capsule Archives

Capsule Home


Want more?


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


Subscribe to the Capsule's Feed

Checkout the FatScript project on GitLab

Checkout my projects on GitHub

Checkout my projects on SourceHut


© aprates.dev, 2021-2023 - content on this site is licensed under

Creative Commons BY-NC-SA 4.0 License

Proudly built with GemPress

Privacy Policy

-- Response ended

-- Page fetched on Tue May 21 10:20:01 2024