69

Let's say I have created a 100-page book with the book document class.

What is the quickest way to extract, say, pages 3, 67-70, and 80 from the book into six separate PDF files? Is there any standard tool/script out there that does this very quickly?

Manually doing this through a UI is rather tedious.

1
  • You may also want to look at this tool: pdfShuffler
    – kan
    Commented Oct 29, 2012 at 23:28

5 Answers 5

74

You can use the pdfjam tool with the syntax

pdfjam <input file> <page ranges> -o <output file>

and an example of page ranges would be

3,67-70,80

to extract page 3, pages 67 to 70 and page 80, and put these pages into a single document. Note however that this will break the hyperlinks in your document.

[edit] pdfjam is actually a front end for pdfpages, suggested in an other answer.

You could also use pdfseparate from poppler to burst a document into separate pages. Using

pdfseparate <document> 'page_%d.pdf'

using the result of pdfjam as a document will give you files named page_1.pdf … page_6.pdf containing all the desired pages.

2
  • 1
    It will remove all of the hyperlinks, so this method should be discouraged. Commented Jan 23, 2019 at 23:30
  • @JongwookChoi: Do you know of a method that does not remove hyperlinks as I thought they all did. I can understand why it might be complicated to retain internal links, but external links should be able to be kept. Commented Jul 25, 2019 at 23:29
41

You can do this with the pdfpages package.

Code:

\documentclass{article}
\usepackage{pdfpages}

\begin{document}
    \includepdf[pages={3,67-70,80}]{<pdf-file>}
\end{document}
1
  • If your pdf does not have the same format as article (or another easy default), you can use the fitpaper key to \includepdf to have the paper size automatically adjusted.
    – schtandard
    Commented Jun 30, 2023 at 17:59
19

You can perform lots of tasks with pdf files using pdftk. For example,

pdftk big_file.pdf cat 3 output page3.pdf

creates a new file page3.pdf from page 3 of big_file.pdf. You can also use ranges; replacing 3 with 67-70 extracts pages 67-70.

2
  • 2
    If I remember right there's also a burst directive to split it into single page files. Commented Oct 30, 2012 at 8:08
  • 1
    Yes. But: not avalable in Centos7
    – gdm
    Commented May 13, 2015 at 14:39
7

Use PDFtk (the manual is here),

pdftk "input.pdf" cat 3 67-70 80 output "output.pdf"
2

PDFsam (PDF split and merge) is a little more general tool I use often. It now comes in different flavors, with

PDFsam Basic, a free and open source solution for casual users. Split, merge, mix, extract pages and rotate PDF files.

1
  • 1
    PDFsam Basic is free and it's easy to use. thanks.
    – Evan Hu
    Commented May 29, 2022 at 9:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .