How to Extract PDF Pages from the Linux Command Line

Quick Linux Tip #68:

Question: How do I split or extract pages from a PDF without a GUI?

Try: pdftk input.pdf cat 5-10 output pages_5_to_10.pdf

Info: pdftk manipulates PDFs from the command line. cat 5-10 extracts pages 5 through 10, while pdfinfo can inspect PDF metadata and page counts.

Examples:

  • $ pdftk file1.pdf file2.pdf cat output merged.pdf  # Merge multiple PDFs
  • $ pdftk input.pdf cat 1 3 5-10 output selected.pdf  # Extract custom page ranges
  • $ qpdf --empty --pages input.pdf 1-5 -- output.pdf  # Use qpdf as a modern alternative

Note: Install pdftk with sudo apt install pdftk-java. Use end to target the final page, such as cat 5-end. qpdf is another useful command-line PDF tool.




LinuxTeck.com
linuxteck:~$ pdfinfo input.pdf | grep Pages
Pages:          234

linuxteck:~$ pdftk input.pdf cat 5-10 output pages_5_to_10.pdf

linuxteck:~$ pdfinfo pages_5_to_10.pdf | grep Pages
Pages:          6

linuxteck:~$ ls -la pages_5_to_10.pdf
-rw-r--r-- 1 linuxteck linuxteck 456789 Sep 11 10:23 pages_5_to_10.pdf
linuxteck:~$

PREVIOUS ARTICLE Quick Linux Tip #67: How to Test SSD Speed in Linux with hdparm and dd
About John Britto

John Britto Founder & Chief-Editor @LinuxTeck. A Computer Geek and Linux Intellectual having more than 20+ years of experience in Linux and Open Source technologies.

View all posts by John Britto →

Leave a Reply

Your email address will not be published.