Thomas' Tech Tips

Extract specific pages from PDF

28 July 2023 - Thomas Damgaard

To extract or delete specific pages from a PDF on Debian, you can use the pdftk (PDF Toolkit) tool.

Follow these steps:

Install pdftk

If you don’t have pdftk installed on your Debian system, you can install it by running the following command in the terminal:

sudo apt-get install pdftk

Delete pages from the PDF

Once pdftk is installed, use the following command to delete the desired pages from the PDF file. Replace <input_file> with the path to your original PDF file, and <output_file> with the desired name of the resulting PDF file without the deleted pages.

pdftk <input_file> cat <page_ranges> output <output_file>

For example to extract page 42 from a PDF, run:

pdftk original.pdf cat 42 output new.pdf

This will create a new.pdf containing only page 42 from the original pdf.

Ranges can be used as well. In order to delete the first page then keep pages 2-10 and delete the rest:

pdftk original.pdf cat 2-10 output new.pdf

In the example above, 2-10 specifies the page range to keep. Adjust the page ranges according to your specific requirements.

Filed under: howto, linux, pdf, tips

Back to article list