pikepdf9.4.2
Published
Read and write PDFs with Python, powered by qpdf
pip install pikepdf
Package Downloads
Authors
Project URLs
Requires Python
>=3.9
Dependencies
- Pillow
>=10.0.1
- Deprecated
- lxml
>=4.8
- packaging
- pre-commit
; extra == "dev"
- typer
; extra == "dev"
- Sphinx
>=3; extra == "docs"
- sphinx-autoapi
; extra == "docs"
- sphinx-design
; extra == "docs"
- sphinx-issues
; extra == "docs"
- sphinx-rtd-theme
; extra == "docs"
- tomli
; python_version < "3.11" and extra == "docs"
- lxml-stubs
; extra == "mypy"
- types-Pillow
; extra == "mypy"
- types-requests
; extra == "mypy"
- types-setuptools
; extra == "mypy"
- attrs
>=20.2.0; extra == "test"
- coverage
[toml]; extra == "test"
- hypothesis
>=6.36; extra == "test"
- pybind11
; extra == "test"
- pytest
>=6.2.5; extra == "test"
- pytest-cov
>=3.0.0; extra == "test"
- pytest-timeout
>=2.1.0; extra == "test"
- pytest-xdist
>=2.5.0; extra == "test"
- python-dateutil
>=2.8.1; extra == "test"
- psutil
>=5.9; os_name != "nt" and extra == "test"
- python-xmp-toolkit
>=2.0.1; (os_name != "nt" and platform_machine == "x86_64") and extra == "test"
- numpy
>=1.21.0; (platform_machine == "x86_64" and platform_python_implementation == "CPython") and extra == "test"
- tomli
; python_version < "3.11" and extra == "test"
pikepdf
pikepdf is a Python library for reading and writing PDF files.
pikepdf is based on qpdf, a powerful PDF manipulation and repair library.
Python + qpdf = "py" + "qpdf" = "pyqpdf", which looks like a dyslexia test. Say it out loud, and it sounds like "pikepdf".
# Elegant, Pythonic API
with pikepdf.open('input.pdf') as pdf:
num_pages = len(pdf.pages)
del pdf.pages[-1]
pdf.save('output.pdf')
To install:
pip install pikepdf
For users who want to build from source, see installation.
pikepdf is documented and actively maintained. Binary wheels are available for all common platforms, both x86-64 and ARM64/Apple Silicon. For information on the latest changes, see the release notes.
Commercial support is available.
Features
This library is similar to pypdf (formerly PyPDF2) - it provides low level access to PDF features and allows editing and content transformation of existing PDFs. Some knowledge of the PDF specification may be helpful. It does not have the capability to render a PDF to image.
Feature | pikepdf | pypdf (PyPDF2) |
---|---|---|
Editing, manipulation and transformation of existing PDFs | ✔ | ✔ |
Based on an existing, mature PDF library | qpdf | ✘ |
Implementation | C++ and Python | Python |
PDF versions supported | 1.1 to 1.7 | 1.1 to 1.7 |
Save and load password protected (encrypted) PDFs | ✔ (except public key) | ✔ (except public key) |
Creates linearized ("fast web view") PDFs | ✔ | ✘ |
Test suite coverage | ||
Creates PDFs that pass PDF validation tests | ✔ | ✘ |
Modifies PDF/A without breaking PDF/A compliance | ✔ | ✘ |
PDF XMP metadata editing | ✔ | read-only |
Integrates with Jupyter and IPython notebooks for rapid development | ✔ | ✘ |
Testimonials
I decided to try writing a quick Python program with pikepdf to automate [something] and it "just worked". –Jay Berkenbilt, creator of qpdf
"Thanks for creating a great pdf library, I tested out several and this is the one that was best able to work with whatever I threw at it." –@cfcurtis
In Production
-
OCRmyPDF uses pikepdf to graft OCR text layers onto existing PDFs, to examine the contents of input PDFs, and to optimize PDFs.
-
PDF Arranger is a small Python application that provides a graphical user interface to rotate, crop and rearrange PDFs.
-
PDFStitcher is a utility for stitching PDF pages into a single document (i.e. N-up or page imposition).
License
pikepdf is licensed under the Mozilla Public License 2.0 license (MPL-2.0) that can be found in the LICENSE file. By using, distributing, or contributing to this project, you agree to the terms and conditions of this license. MPL 2.0 permits you to combine the software with other work, including commercial and closed source software, but asks you to publish source-level modifications you make to pikepdf itself.
Some components of the project may be under other license agreements, as indicated in their SPDX license header or the REUSE.toml
file.