Split PDF document from command line in Linux?
Solution 1:
I find pdfseparate very convenient to split ranges into individual pages. This command would extract pages 1 - 5 of input.pdf
into files named output-page1.pdf
, output-page2.pdf
, ...
pdfseparate -f 1 -l 5 input.pdf output-page%d.pdf
If you want to recombine them into page ranges, for example pages 1-3 in one document and pages 4-5 in another, you can use the companion program, pdfunite, as follows:
pdfunite output-page1.pdf output-page2.pdf output-page3.pdf final-pages1-3.pdf
pdfunite output-page4.pdf output-page5.pdf final-pages4-5.pdf
I believe theese tools are part of poppler and may already be installed on your system.
Solution 2:
Using pdftk 2.02 worked for me on debian, but I think it should work for you too.
pdftk input.pdf cat 2-4 output out1.pdf
For a general case where you have to split a single pdf to multiple files I could not find a way with pdftk, so I'm using a Bash script.