To extract pdf pages from several files, we can use the open source tool qpdf.
First we can install qpdf using homebrew:
brew install qpdf
Suppose you want to extract page 1-2 from A.pdf
, page 1 from B.pdf
and page 3-4 from C.pdf
,
you can run the following command:
qpdf --empty --pages A.pdf 1-2 B.pdf 1 C.pdf 3-4 -- output.pdf
--empty
means there is no input pdf, we are trying to produce a new PDF from existing ones.
Between --page
and final --
, we can specify multiple PDF files with range, password info in this format:
filename [--password=password] [page-range]
Both password and page-range is optional. If you don’t specify the page range, it will take the whole pdf. For more details, run the following command on command line:
qpdf --help=page-selection
References#
- https://qpdf.readthedocs.io/en/stable/overview.html
- How can I extract a page range / a part of a PDF: https://askubuntu.com/a/672001/768311