How to Use pdftk in Linux to Extract Specific Pages from a PDF File

Working with large PDF documents often requires you to extract only a few specific pages to share with others or keep for your own records. While many graphical PDF editors exist, the Linux command line offers a lightweight and incredibly fast tool called pdftk (PDF Toolkit). This tool allows you to slice, merge, and manipulate PDF files with simple terminal commands.

Why Use pdftk?

Graphical PDF editors can be resource-intensive and sometimes require paid licenses to perform advanced operations like page extraction. pdftk is free, open-source, and runs efficiently even on low-powered hardware or headless servers. Because it operates from the command line, it is also perfect for automating bulk PDF extraction tasks using bash scripts.

Step 1: Install pdftk on Linux

Before you can extract pages, you need to ensure the toolkit is installed on your system. It is available in the default repositories of most major Linux distributions.

  1. Open your terminal application.
  2. For Ubuntu, Debian, or Linux Mint, update your package list and install the tool using the following commands:
sudo apt update
sudo apt install pdftk
  1. For Fedora or RHEL-based systems, use:
sudo dnf install pdftk

Once the installation completes, you can verify it by typing pdftk --version.

Step 2: Extract a Single Page

Extracting a single page from a document requires defining the input file, the page number, and the output file.

  1. Navigate to the directory containing your PDF file using the cd command.
  2. Run the following command to extract a single page (for example, page 5 from document.pdf):
pdftk document.pdf cat 5 output page_5.pdf

The cat command tells pdftk to concatenate (or in this case, isolate) the specified pages, and the output flag defines the name of the new file.

Step 3: Extract a Range of Pages

You can also extract a continuous block of pages just as easily.

  1. To extract pages 5 through 10 from the original document, use a hyphen:
pdftk document.pdf cat 5-10 output pages_5_to_10.pdf
  1. If you want to extract multiple non-consecutive pages (e.g., pages 1, 3, and 7), simply separate the page numbers with a space:
pdftk document.pdf cat 1 3 7 output selected_pages.pdf
  1. You can even combine ranges and individual pages (e.g., page 1, and pages 4 through 6):
pdftk document.pdf cat 1 4-6 output combined_pages.pdf

Using pdftk makes manipulating PDF documents on Linux incredibly fast, eliminating the need for bloated graphical software for simple extraction tasks.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.