Read and write PDFs with Python, powered by qpdf
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 pdf = pikepdf.open('input.pdf') num_pages = len(pdf.pages) del pdf.pages[-1] pdf.save('output.pdf')
Python 3.5, 3.6 and 3.7 are fully supported.
pip install pikepdf
For users who want to build from source, see installation.
pikepdf is documented and actively maintained. Commercial support is available.
This library is similar to PyPDF2 and pdfrw - 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.
Python 2.7 and earlier versions of Python 3 are not currently supported but support is probably not difficult to achieve. Pull requests are welcome.
|Editing, manipulation and transformation of existing PDFs||✔||✔||✔|
|Based on an existing, mature PDF library||QPDF||✘||✘|
|PDF versions supported||1.1 to 1.7||1.3?||1.7|
|Python versions supported||3.5-3.7||2.6-3.6||2.6-3.6|
|Supports password protected (encrypted) PDFs||✔ (except public key)||Only obsolete RC4||✘|
|Save and load PDF compressed object streams (PDF 1.5)||✔||✘||✘|
|Creates linearized ("fast web view") PDFs||✔||✘||✘|
|Test suite coverage||~86%||very low||unknown|
|Creates PDFs that pass PDF validation tests||✔||✘||?|
|Modifies PDF/A without breaking PDF/A compliance||✔||✘||?|
|Automatically repairs PDFs with internal errors||✔||✘||✘|
|Integrates with Jupyter and IPython notebooks for rapid development||✔||✘||✘|
pikepdf is provided under the Mozilla Public License 2.0 license (MPL) 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.
Informally, MPL 2.0 is a not a "viral" license. It may be combined with other work, including commercial software. However, you must disclose your modifications to pikepdf in source code form. In other works, fork this repository on GitHub or elsewhere and commit your contributions there, and you've satisfied your obligations. MPL 2.0 is compatible with the GPL and LGPL - see the guidelines for notes on use in GPL.
tests/resources/copyright file describes licensing terms for the test suite and the provenance of test resources.
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.