I would like to extract page ranges from a PDF document into a new PDF document using the command line in Linux. Note that:
- PDFtk - The PDF Toolkit fails for me with:
$ pdftk input.pdf cat 1 verbose output output.pdf Error: Failed to open PDF file: input.pdf Errors encountered. No output created. Done. Input errors, so no output created.
From here:
You (should) know that Pdftk is nothing more than a very old version of iText (a Java-PDF library) compiled with GCJ and extended with some command line functionality.
The keywords in the above statement are "VERY OLD".
- Multivalent also fails:
$ java -classpath /path/to/Multivalent20091027.jar tool.pdf.Split -page 1 input.pdf Exception in thread "main" java.lang.NoClassDefFoundError: tool/pdf/Split Caused by: java.lang.ClassNotFoundException: tool.pdf.Split at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) Could not find the main class: tool.pdf.Split. Program will exit.
Turns out, this is a bit of a tricky software: even if it's on SourceForge, and says here that
Practical Thought generously provides these tools for free use on the command line
However, here it says:
The browser is open source. The document tools are a free bonus and not open source.
Which finally clarifies the comment from conversion - Gluing (Imposition) PDF documents - Stack Overflow:
All releases of Multivalent linked from the official sourceforge site are missing the tools package.
(edit: there seems to be an old Multivalent version with the tools included, see the SO link; but as it looks somewhat like abandonware, I'd rather not use it)
Finally, I'd like to avoid tools that are essentially front ends for LaTeX like pdfjam.
Are there any options for such a PDF splitting command line tool under Linux?
qpdf --split-pages=2 in.pdf out-%d.pdf
, see this answer for more. To extract a range of pages, 2 to 5 in this example:qpdf --empty --pages in.pdf 2-5 -- out.pdf
, see also this.