Skip to main content

Read and write PDFs with Python, powered by qpdf

Project description

pikepdf

pikepdf is a Python library for reading and writing PDF files.

Build Status PyPI PyPI - Python Version PyPy PyPI - License PyPI - Downloads codecov

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.

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.3?
Python versions supported 3.8-3.11 [^1] 2.7-3.10
Save and load 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 codecov codecovpypdf2
Creates PDFs that pass PDF validation tests
Modifies PDF/A without breaking PDF/A compliance
Automatically repairs PDFs with internal errors
PDF XMP metadata editing read-only
Documentation
Integrates with Jupyter and IPython notebooks for rapid development

[^1]: pikepdf 3.x and older support Python 3.6.

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 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. Some components of the project may be under other license agreements, as indicated in their SPDX license header or the .dep5/reuse file.

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.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pikepdf-7.1.0.tar.gz (2.9 MB view hashes)

Uploaded Source

Built Distributions

pikepdf-7.1.0-pp39-pypy39_pp73-win_amd64.whl (3.3 MB view hashes)

Uploaded PyPy Windows x86-64

pikepdf-7.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pikepdf-7.1.0-pp39-pypy39_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (2.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

pikepdf-7.1.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pikepdf-7.1.0-pp38-pypy38_pp73-win_amd64.whl (3.3 MB view hashes)

Uploaded PyPy Windows x86-64

pikepdf-7.1.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

pikepdf-7.1.0-pp38-pypy38_pp73-manylinux_2_17_i686.manylinux2014_i686.whl (2.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ i686

pikepdf-7.1.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

pikepdf-7.1.0-cp311-cp311-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

pikepdf-7.1.0-cp311-cp311-win32.whl (2.8 MB view hashes)

Uploaded CPython 3.11 Windows x86

pikepdf-7.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

pikepdf-7.1.0-cp311-cp311-manylinux_2_17_i686.manylinux2014_i686.whl (2.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ i686

pikepdf-7.1.0-cp311-cp311-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

pikepdf-7.1.0-cp310-cp310-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

pikepdf-7.1.0-cp310-cp310-win32.whl (2.8 MB view hashes)

Uploaded CPython 3.10 Windows x86

pikepdf-7.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

pikepdf-7.1.0-cp310-cp310-manylinux_2_17_i686.manylinux2014_i686.whl (2.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ i686

pikepdf-7.1.0-cp310-cp310-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

pikepdf-7.1.0-cp39-cp39-win_amd64.whl (3.2 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

pikepdf-7.1.0-cp39-cp39-win32.whl (2.8 MB view hashes)

Uploaded CPython 3.9 Windows x86

pikepdf-7.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

pikepdf-7.1.0-cp39-cp39-manylinux_2_17_i686.manylinux2014_i686.whl (2.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ i686

pikepdf-7.1.0-cp39-cp39-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

pikepdf-7.1.0-cp38-cp38-win_amd64.whl (3.3 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

pikepdf-7.1.0-cp38-cp38-win32.whl (2.8 MB view hashes)

Uploaded CPython 3.8 Windows x86

pikepdf-7.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

pikepdf-7.1.0-cp38-cp38-manylinux_2_17_i686.manylinux2014_i686.whl (2.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ i686

pikepdf-7.1.0-cp38-cp38-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page