Skip to main content

pdfpages

https://img.shields.io/pypi/v/pdfpages.svg?style=flat-square:https://pypi.python.org/pypi/pdfpages: https://img.shields.io/github/license/philbooth/pdfpages.svg?style=flat-square:target:https://opensource.org/licenses/MIT

Extract specific pages from PDF documents.

What is it?

A python package that extracts pages from PDF documents and writes them to a fresh PDF.

How do I install it?

Via pip:

pip install pdfpages

Or if you just want the git repo:

git clone git@github.com:philbooth/pdfpages.git

How do I run it on the command line?

pdfpages -o out.pdf in.pdf

The -o option is used to specify the output path and the final argument is the path to the input document. You can specify multiple input documents by listing further paths at the end of the command:

pdfpages -o out.pdf in1.pdf in2.pdf
pdfpages -o out.pdf in/*.pdf

Without other arguments, the default behaviour is to extract the first page from each input document and write the result to the output PDF.

If you want to extract specific pages, you can use the -p option. For instance, to extract just the second page from each input document you woud run:

pdfpages -p 2 -o out.pdf in/*.pdf

Or to extract the second and third pages from each document:

pdfpages -p 2 3 -o out.pdf in/*.pdf

You can also use the -f and -c options to specify ranges of page numbers. For instance, to extract the first hundred pages from each document:

pdfpages -f 1 -c 100 -o out.pdf in/*.pdf

Or to extract the second hundred pages:

pdfpages -f 101 -c 100 -o out.pdf in/*.pdf

You can exclude specific pages from these ranges with the -e option. For example, to exclude the third page from the first five pages of each input document:

pdfpages -f 1 -c 5 -e 3 -o out.pdf in/*.pdf

Finally, you can see the usage information at any time using the -h option:

python pdfpages.py -h

How do I call it from python code?

import pdfpages

pdfpages.extract(in_files, out_file, pages, exclude_pages)
  • in_files: A tuple containing files opened for binary reading (mode "rb").

  • out_file: A file opened for binary writing (mode "wb").

  • pages: A tuple containing page numbers to extract (integers).

  • exclude_pages: An optional tuple containing page numbers to exclude from extraction (integers). Defaults to an empty tuple.

What license is it released under?

MIT

Metadata

Release files for pdfpages 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdfpages 0.1.0
File Size Uploaded Provenance Actions
pdfpages-0.1.0.tar.gz 3.2 kB Without provenance Details for pdfpages-0.1.0.tar.gz

Release files / pdfpages-0.1.0.tar.gz

Download URL pdfpages-0.1.0.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
efe90a81891d67f10ea0d0dc8dab328422c0b8231792a1c049c71ec439e6f053
BLAKE2b-256 checksum
How to use checksums
79ee44ae1743687fa3d92bd5990c4f130743cdce865b332252bcae4892bf8076
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pdfpages 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page