pikepdf
Read, write, repair, and transform PDFs in Python, powered by qpdf
What it is and what it does
pikepdf is a Python wrapper around qpdf, a mature C++ PDF library, that lets you read, modify, and repair PDF documents programmatically. It handles page operations (merge, split, rotate, rearrange), metadata editing (XMP and DocumentInfo), encryption/decryption (AES-256, AES-128, RC4), lossless image extraction, and direct access to PDF objects. The library automatically repairs structural damage when opening malformed PDFs, making it useful for sanitizing or normalizing documents.
It runs on modern Python (3.10+) and comes pre-built for Linux, macOS, and Windows on both x86-64 and ARM64 architectures, including free-threaded CPython 3.14. Three runtime dependencies (Pillow, lxml, packaging) keep the footprint manageable. pikepdf is not designed for PDF generation from HTML/templates, rendering to images, or text extraction—other libraries are better suited for those tasks.
Use it for:
- Merge multiple PDFs into a single document or split and rearrange pages across files
- Repair damaged or malformed PDFs automatically on open, then save corrected versions
- Edit PDF metadata (title, author, creation date) and XMP properties programmatically
- Extract images from PDFs losslessly without re-encoding JPEG or other compressed formats
- Open password-protected PDFs and re-save with different encryption or no encryption
- Optimize PDFs for web delivery using linearization (fast web view)
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pikepdf reads, writes, repairs, and transforms PDF documents through a Python interface backed by the qpdf C++ library, handling page manipulation, metadata editing, encryption, and low-level PDF object access.
Yes. pikepdf is production-ready (stable since 2017, actively maintained, no known vulnerabilities), has broad platform support via pre-built wheels, and solves real PDF manipulation problems that pure-Python libraries struggle with. The MPL-2.0 license is permissive for most use cases. Install it if you need to repair, merge, encrypt, or manipulate existing PDFs; skip it if you only need text extraction or PDF rendering.
Install
pikepdf on PyPI
pip
pip install pikepdfuv
uv add pikepdfpoetry
poetry add pikepdfInstalling pikepdf
Before you install
Medium install friction due to compiled C++ dependencies, but binary wheels are pre-built for common platforms (Linux, macOS, Windows on x86-64 and ARM64) requiring no compiler. Active maintenance with a release 14 days ago and 2789 repository stars.
License in practice
Licensed under MPL-2.0 (copyleft), which requires source code disclosure of modifications to pikepdf itself but permits both open and closed source projects to use it. Compatible with most commercial and open source projects.
Quickstart
pip install pikepdf
import pikepdf
with pikepdf.Pdf.open('input.pdf') as pdf:
num_pages = len(pdf.pages)
del pdf.pages[-1]
pdf.save('output.pdf')
Requires Python 3.10 or later; binary wheels available for most platforms, but source builds require a C++ compiler.
Verify before relying
- Whether qpdf's automatic repair handles all common PDF corruption patterns in practice
- Performance characteristics for very large PDFs or batch operations
Package facts
| License | MPL-2.0 (copyleft) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 3 — Pillow, lxml, packaging |
| Maintenance | actively maintained — 14 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 10,269,759/month — #1,463 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pikepdf-10.11.0-cp310-cp310-macosx_14_0_arm64.whl; pikepdf-10.11.0-cp310-cp310-macosx_15_0_x86_64.whl; pikepdf-10.11.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; pikepdf-10.11.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pikepdf-10.11.0-cp310-cp310-musllinux_1_2_aarch64.whl; pikepdf-10.11.0-cp310-cp310-musllinux_1_2_x86_64.whl; pikepdf-10.11.0-cp310-cp310-win_amd64.whl; pikepdf-10.11.0-cp311-cp311-macosx_14_0_arm64.whl; pikepdf-10.11.0-cp311-cp311-macosx_15_0_x86_64.whl; pikepdf-10.11.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; pikepdf-10.11.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pikepdf-10.11.0-cp311-cp311-musllinux_1_2_aarch64.whl; pikepdf-10.11.0-cp311-cp311-musllinux_1_2_x86_64.whl; pikepdf-10.11.0-cp311-cp311-win_amd64.whl; pikepdf-10.11.0-cp312-cp312-macosx_14_0_arm64.whl; pikepdf-10.11.0-cp312-cp312-macosx_15_0_x86_64.whl; pikepdf-10.11.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; pikepdf-10.11.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl; pikepdf-10.11.0-cp312-cp312-musllinux_1_2_aarch64.whl; pikepdf-10.11.0-cp312-cp312-musllinux_1_2_x86_64.whl
Keywords: PDF
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
PyPDF4PyPDF4 is a pure-Python PDF toolkit for…
permissive · top 15,000 on PyPI
PyPDF3PyPDF3 is a pure-Python PDF toolkit for…
permissive · top 15,000 on PyPI
pdfrwpdfrw reads, writes, and manipulates PDF files…
permissive · top 5,000 on PyPI
pdfrw2pdfrw2 reads, writes, and manipulates PDF files…
permissive · top 15,000 on PyPI
PyPDF2PyPDF2 is a pure-Python library for reading,…
permissive · top 1,000 on PyPI
ocrmypdfOCRmyPDF adds searchable text layers to scanned…
copyleft · top 5,000 on PyPI
pdfservices-sdkClient library for Adobe PDF Services API,…
permissive · top 15,000 on PyPI
convertapiA Python client for the ConvertAPI online file…
permissive · top 15,000 on PyPI
pypdfpypdf is a pure-Python library for reading,…
permissive · top 1,000 on PyPI
pypdfium2pypdfium2 is a Python binding to PDFium that…
permissive · top 1,000 on PyPI