Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to split PDF using PDFTK

📅 2010-Feb-08 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ batch files, pdf, pdftk, split ⬩ 📚 Archive

PDFTK can be used to easily split out pages of a PDF file into separate PDF files at the shell. It is available for both Linux and Windows.

To install PDFTK, please follow the instructions here. To split a PDF file into multiple PDF files, one per page of the original PDF file, invoke:

$ pdftk foobar.pdf burst output foobar-%d.pdf

If foobar.pdf is a 2 page PDF, this splits it into foobar-1.pdf and foobar-2.pdf.

If you split often, it would be much nicer to invoke the above simply as:

$ splitpdf foobar

To be able to do that on Windows, you can turn the above invocation into a batch file:

REM splitpdf.bat
pdftk %1.pdf burst output %1-%%d.pdf

The %1 is the first input argument to the batch file invocation. And %% is the way to escape %, which is a special character in a batch file.

Reference: Beamer + Ipe + views


© 2022 Ashwin Nanjappa • All writing under CC BY-SA license • 🐘 @codeyarns@hachyderm.io📧