pikepdf 10.5.1


pip install pikepdf

  Latest version

Released: Mar 18, 2026


Meta
Author: James R. Barlow
Requires Python: >=3.10

Classifiers

Development Status
  • 5 - Production/Stable

Intended Audience
  • Developers
  • Information Technology

Programming Language
  • Python :: Free Threading :: 1 - Unstable

Topic
  • Multimedia :: Graphics
  • Software Development :: Libraries

pikepdf

Read, write, repair, and transform PDFs in Python -- powered by qpdf.

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

pikepdf is based on qpdf, a mature, actively maintained C++ library for PDF manipulation and repair.

Python + qpdf = "py" + "qpdf" = "pyqpdf", which looks like a dyslexia test. Say it out loud, and it sounds like "pikepdf".

import pikepdf

# Open a PDF -- pikepdf (via qpdf) automatically repairs structural damage
with pikepdf.Pdf.open('input.pdf') as pdf:
    num_pages = len(pdf.pages)
    del pdf.pages[-1]
    pdf.save('output.pdf')

Installation

pip install pikepdf

Binary wheels are available for all common platforms -- Linux, macOS, and Windows on both x86-64 and ARM64/Apple Silicon. No compiler required.

For building from source, see installation. Commercial support is available.

What Can pikepdf Do?

Manipulate pages

Merge, split, rotate, and rearrange pages across PDFs.

from pikepdf import Pdf

# Merge multiple PDFs
with Pdf.new() as merged:
    for filename in ['first.pdf', 'second.pdf', 'third.pdf']:
        src = Pdf.open(filename)
        merged.pages.extend(src.pages)
    merged.save('merged.pdf')
# Rotate all pages in a document
with Pdf.open('input.pdf') as pdf:
    for page in pdf.pages:
        page.rotate(180, relative=True)
    pdf.save('rotated.pdf')

Edit metadata

Read and write XMP metadata and DocumentInfo, with automatic synchronization between the two.

import pikepdf

with pikepdf.open('report.pdf') as pdf:
    with pdf.open_metadata() as meta:
        meta['dc:title'] = 'Quarterly Report'
        meta['dc:creator'] = ['Author Name']
    pdf.save('updated.pdf')

Extract images

Extract images losslessly from PDFs -- without re-encoding JPEGs or other compressed formats.

from pikepdf import Pdf, PdfImage

with Pdf.open('document.pdf') as pdf:
    for page in pdf.pages:
        for name, raw_image in page.images.items():
            image = PdfImage(raw_image)
            image.extract_to(fileprefix='output')

Encrypt and decrypt

Open password-protected PDFs and save with encryption (AES-256, AES-128, or RC4).

import pikepdf

# Open an encrypted PDF
with pikepdf.open('protected.pdf', password='secret') as pdf:
    pdf.save('decrypted.pdf')

# Save with encryption
with pikepdf.open('input.pdf') as pdf:
    pdf.save('encrypted.pdf', encryption=pikepdf.Encryption(
        user='readpassword', owner='adminpassword'
    ))

# Remove encryption if user password is not set
with pikepdf.open('protected.pdf') as pdf:
    pdf.save('decrypted.pdf', encryption=False)

(Digital signature-based encryption is not currently supported.)

Linearize to improve browser performance

Create "fast web view" PDFs optimized for streaming delivery.

with pikepdf.open('input.pdf') as pdf:
    pdf.save('web_optimized.pdf', linearize=True)

Access PDF objects directly

Use a Pythonic API that mirrors the PDF specification -- dictionaries, arrays, streams, and names map directly to Python types.

from pikepdf import Pdf, Name

with Pdf.open('input.pdf') as pdf:
    page = pdf.pages[0]
    page.MediaBox               # e.g. [0, 0, 612, 792]
    page.Resources.XObject      # image and form XObjects on this page
    page.Rotate = 90            # set page rotation directly

Use qpdf's Job API

Access qpdf's full command-line capabilities programmatically from Python.

from pikepdf import Job

# Check a PDF for errors
Job(['pikepdf', '--check', 'document.pdf']).run()

# Or use qpdf's JSON job interface
Job({'inputFile': 'input.pdf', 'outputFile': 'output.pdf', 'linearize': ''}).run()

Key Features

  • Built on qpdf -- backed by a mature, battle-tested C++ PDF library
  • Automatic PDF repair -- silently fixes many types of PDF damage on open
  • PDF/A compliance -- modify PDFs without breaking PDF/A conformance
  • XMP metadata editing -- full read/write support for XMP and DocumentInfo
  • Encryption support -- open and save password-protected PDFs (AES-256, AES-128, RC4)
  • Linearization -- create "fast web view" PDFs for efficient streaming
  • Pythonic API -- dictionary-style access to PDF objects, list-style page access
  • Lossless image extraction -- extract and replace images without re-encoding
  • Content stream inspection -- parse and manipulate page content at the operator level
  • Object-level manipulation -- work directly with PDF objects per the specification
  • Jupyter integration -- render PDF and page previews inline in notebooks
  • Binary wheels everywhere -- pre-built for Linux, macOS, Windows (x86-64 and ARM64)
  • Liberal license -- MPL-2.0, compatible with most open and closed source projects

When to Use pikepdf

pikepdf is a great fit when you need to:

  • Repair, sanitize, or normalize damaged or malformed PDFs
  • Merge, split, rotate, crop, or rearrange pages
  • Edit PDF metadata (XMP, DocumentInfo) programmatically
  • Build tools or libraries that operate on existing PDFs
  • Preserve PDF/A or other standard compliance while modifying documents
  • Work with encrypted PDFs
  • Perform low-level PDF surgery (object and stream manipulation)
  • Optimize PDFs for web delivery (linearization)

pikepdf is probably not what you want if you need to:

PDF Libraries in Python

Python has several PDF libraries, each with different strengths. pypdf is pure Python and well-suited for straightforward PDF tasks without compiled dependencies. pypdfium for permissively licensed PDF rendering. PyMuPDF offers comprehensive rendering and text extraction. pikepdf focuses on correctness, repair, and low-level manipulation through qpdf, under the permissive MPL-2.0 license.

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

Used By

  • 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).

Documentation

Full documentation is available at pikepdf.readthedocs.io. For the latest changes, see the release notes.

Contributing

Contributions are welcome! If you'd like to make a contribution, see the Contributing Guidelines

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.

10.5.1 Mar 18, 2026
10.5.0 Mar 10, 2026
10.3.0 Jan 30, 2026
10.2.0 Jan 09, 2026
10.1.0 Dec 23, 2025
10.0.3 Dec 17, 2025
10.0.2 Nov 10, 2025
10.0.1 Nov 09, 2025
10.0.0 Oct 26, 2025
10.0.0rc1 Oct 25, 2025
9.11.0 Sep 12, 2025
9.10.2 Jul 17, 2025
9.10.1 Jul 16, 2025
9.10.0 Jul 14, 2025
9.9.0 Jun 18, 2025
9.8.1 May 27, 2025
9.8.0 May 27, 2025
9.7.0 Apr 07, 2025
9.6.0 Apr 05, 2025
9.5.2 Feb 07, 2025
9.5.1 Jan 03, 2025
9.5.0 Jan 02, 2025
9.4.2 Nov 17, 2024
9.4.1 Nov 13, 2024
9.4.0 Oct 27, 2024
9.3.0 Sep 30, 2024
9.2.1 Sep 02, 2024
9.2.0 Aug 23, 2024
9.1.2 Aug 21, 2024
9.1.1 Aug 08, 2024
9.1.0 Jul 23, 2024
9.0.0 May 31, 2024
9.0.0rc1 May 24, 2024
8.15.1 Apr 16, 2024
8.15.0 Apr 07, 2024
8.14.0 Mar 23, 2024
8.13.0 Feb 15, 2024
8.12.0 Feb 02, 2024
8.11.2 Jan 01, 2024
8.11.1 Dec 30, 2023
8.11.0 Dec 28, 2023
8.10.1 Dec 17, 2023
8.10.0 Dec 16, 2023
8.9.0 Dec 10, 2023
8.8.0 Dec 03, 2023
8.7.1 Nov 13, 2023
8.7.0 Nov 13, 2023
8.6.0 Oct 31, 2023
8.5.3 Oct 28, 2023
8.5.2 Oct 21, 2023
8.5.1 Oct 09, 2023
8.5.0 Oct 04, 2023
8.4.2.dev2 Sep 11, 2023
8.4.2.dev1 Sep 11, 2023
8.4.1 Sep 10, 2023
8.4.0 Aug 14, 2023
8.3.2 Aug 12, 2023
8.3.1 Aug 10, 2023
8.3.0 Aug 10, 2023
8.2.3 Aug 01, 2023
8.2.2 Jul 29, 2023
8.2.1 Jul 23, 2023
8.2.0 Jul 22, 2023
8.1.1 Jul 14, 2023
8.0.0 Jul 13, 2023
8.0.0rc3 Jul 11, 2023
8.0.0rc2 Jul 07, 2023
7.2.0 Apr 13, 2023
7.1.2 Mar 25, 2023
7.1.1 Feb 17, 2023
7.1.0 Feb 17, 2023
7.0.0 Feb 05, 2023
7.0.0rc2 Feb 01, 2023
7.0.0rc1 Jan 31, 2023
6.2.9 Jan 26, 2023
6.2.8.post1 Jan 10, 2023
6.2.8 Jan 06, 2023
6.2.7 Dec 31, 2022
6.2.6 Dec 15, 2022
6.2.5 Dec 04, 2022
6.2.4 Nov 13, 2022
6.2.3 Nov 11, 2022
6.2.2 Nov 07, 2022
6.2.1 Oct 20, 2022
6.2.0 Oct 04, 2022
6.1.0 Oct 02, 2022
6.0.2 Sep 19, 2022
6.0.1 Sep 16, 2022
6.0.0.post2 Sep 14, 2022
6.0.0.post1 Sep 13, 2022
5.6.1 Sep 01, 2022
5.6.0 Aug 27, 2022
5.5.0 Aug 20, 2022
5.4.2 Jul 28, 2022
5.4.1 Jul 27, 2022
5.4.0 Jul 17, 2022
5.3.2 Jul 12, 2022
5.3.1 Jul 05, 2022
5.3.0 Jul 04, 2022
5.2.0 Jun 30, 2022
5.1.5.post1 Jun 23, 2022
5.1.5 Jun 10, 2022
5.1.4.post1 Jun 10, 2022
5.1.4 Jun 09, 2022
5.1.3 May 15, 2022
5.1.2 Apr 17, 2022
5.1.1 Mar 29, 2022
5.1.0 Mar 21, 2022
5.0.1 Feb 19, 2022
5.0.0 Feb 17, 2022
4.5.0 Feb 13, 2022
4.4.1 Jan 26, 2022
4.4.0 Jan 25, 2022
4.3.1 Dec 31, 2021
4.3.0 Dec 30, 2021
4.2.0 Dec 11, 2021
4.1.0 Nov 29, 2021
4.0.2 Nov 21, 2021
4.0.1.post1 Nov 09, 2021
4.0.1 Nov 08, 2021
4.0.0 Oct 31, 2021
3.2.0 Oct 10, 2021
3.1.1 Oct 05, 2021
3.1.0 Sep 21, 2021
3.0.0 Sep 06, 2021
3.0.0b3 Aug 25, 2021
3.0.0b2 Aug 20, 2021
3.0.0b1 Aug 14, 2021
2.16.1 Jul 28, 2021
2.16.0 Jul 27, 2021
2.15.1 Jul 20, 2021
2.15.0 Jul 13, 2021
2.14.2 Jul 07, 2021
2.14.1 Jul 07, 2021
2.14.0.post1 Jul 05, 2021
2.14.0 Jul 05, 2021
2.13.0 Jun 22, 2021
2.12.2.post1 Jun 14, 2021
2.12.2 Jun 06, 2021
2.12.1 May 21, 2021
2.12.0 May 09, 2021
2.11.4 Apr 28, 2021
2.11.3 Apr 27, 2021
2.11.2 Apr 23, 2021
2.11.1 Apr 12, 2021
2.11.0 Apr 07, 2021
2.10.0 Mar 30, 2021
2.9.2 Mar 25, 2021
2.9.1 Mar 20, 2021
2.9.0 Mar 15, 2021
2.8.0.post2 Mar 09, 2021
2.8.0.post1 Mar 06, 2021
2.8.0 Mar 01, 2021
2.7.0 Feb 28, 2021
2.6.0 Feb 26, 2021
2.5.2 Feb 01, 2021
2.5.1 Jan 31, 2021
2.5.0 Jan 27, 2021
2.4.0 Jan 16, 2021
2.3.0 Jan 06, 2021
2.2.5 Jan 05, 2021
2.2.4 Dec 29, 2020
2.2.3 Dec 29, 2020
2.2.2 Dec 23, 2020
2.2.1 Dec 20, 2020
2.2.0 Nov 27, 2020
2.1.2 Nov 23, 2020
2.1.1 Nov 18, 2020
2.1.0 Nov 17, 2020
2.0.0 Nov 03, 2020
2.0.0b2 Nov 01, 2020
2.0.0b1 Oct 27, 2020
1.19.4 Nov 08, 2020
1.19.3 Sep 09, 2020
1.19.2 Sep 08, 2020
1.19.1 Sep 06, 2020
1.19.0 Aug 18, 2020
1.18.0 Aug 10, 2020
1.17.3 Jul 25, 2020
1.17.2 Jul 17, 2020
1.17.1 Jul 14, 2020
1.17.0 Jul 07, 2020
1.16.1 Jul 01, 2020
1.16.0 Jun 26, 2020
1.15.1 Jun 20, 2020
1.15.0 Jun 17, 2020
1.14.0 May 31, 2020
1.13.0 May 17, 2020
1.12.0 May 14, 2020
1.11.2 May 04, 2020
1.11.1 Apr 16, 2020
1.11.0 Apr 10, 2020
1.10.4 Apr 02, 2020
1.10.3 Mar 17, 2020
1.10.2 Feb 25, 2020
1.10.1 Feb 10, 2020
1.10.0 Jan 27, 2020
1.9.0 Jan 19, 2020
1.8.3 Jan 06, 2020
1.8.2 Jan 02, 2020
1.8.1 Dec 07, 2019
1.8.0 Dec 07, 2019
1.7.1 Dec 05, 2019
1.7.0 Nov 11, 2019
1.6.5 Oct 20, 2019
1.6.4 Sep 11, 2019
1.6.3 Sep 02, 2019
1.6.2 Aug 26, 2019
1.6.1 Aug 09, 2019
1.6.0 Jul 26, 2019
1.5.0.post0 Jul 09, 2019
1.5.0 Jul 09, 2019
1.4.0 Jun 20, 2019
1.3.1 Jun 14, 2019
1.3.0 May 04, 2019
1.2.0 Apr 14, 2019
1.1.0 Mar 02, 2019
1.0.5 Jan 17, 2019
1.0.4 Jan 08, 2019
1.0.3 Jan 07, 2019
1.0.2 Jan 05, 2019
1.0.1 Jan 04, 2019
1.0.0 Jan 03, 2019
0.10.2 Jan 02, 2019
0.10.1 Dec 31, 2018
0.10.0 Dec 30, 2018
0.9.2 Dec 18, 2018
0.9.1 Dec 15, 2018
0.9.0 Dec 15, 2018
0.3.7.post2 Nov 16, 2018
0.3.7.post1 Nov 16, 2018
0.3.7 Oct 30, 2018
0.3.6 Oct 29, 2018
0.3.5 Oct 12, 2018
0.3.4 Oct 04, 2018
0.3.3 Sep 19, 2018
0.3.2 Aug 20, 2018
0.3.1 Aug 12, 2018
0.3.0 Jul 16, 2018
0.2.2 Jun 28, 2018
0.2.1 Jun 25, 2018
0.2.0 Jun 09, 2018
0.1.10 Jun 06, 2018
0.1.9 May 30, 2018
0.1.8 May 28, 2018
0.1.7 May 26, 2018
0.1.6 May 18, 2018
0.1.5 May 17, 2018
0.1.4 May 16, 2018
0.1.3 May 11, 2018
0.1.2 May 02, 2018
0.1.1 Apr 16, 2018
0.1.0.post1 Apr 07, 2018
0.1.0 Apr 07, 2018
0.1rc5 Nov 10, 2017
0.1rc4 Nov 09, 2017
0.1rc3 Oct 30, 2017
0.1rc2 Oct 30, 2017
0.1rc1 Oct 30, 2017

Wheel compatibility matrix

Platform CPython 3.10 CPython 3.11 CPython 3.12 CPython 3.13 CPython 3.14
macosx_14_0_arm64
macosx_15_0_x86_64
manylinux_2_26_aarch64
manylinux_2_27_x86_64
manylinux_2_28_aarch64
manylinux_2_28_x86_64
musllinux_1_2_aarch64
musllinux_1_2_x86_64
win_amd64

Files in release

pikepdf-10.5.1-cp310-cp310-macosx_14_0_arm64.whl (4.5MiB)
pikepdf-10.5.1-cp310-cp310-macosx_15_0_x86_64.whl (4.8MiB)
pikepdf-10.5.1-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (2.4MiB)
pikepdf-10.5.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6MiB)
pikepdf-10.5.1-cp310-cp310-musllinux_1_2_aarch64.whl (3.5MiB)
pikepdf-10.5.1-cp310-cp310-musllinux_1_2_x86_64.whl (3.7MiB)
pikepdf-10.5.1-cp310-cp310-win_amd64.whl (3.6MiB)
pikepdf-10.5.1-cp311-cp311-macosx_14_0_arm64.whl (4.5MiB)
pikepdf-10.5.1-cp311-cp311-macosx_15_0_x86_64.whl (4.8MiB)
pikepdf-10.5.1-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (2.4MiB)
pikepdf-10.5.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6MiB)
pikepdf-10.5.1-cp311-cp311-musllinux_1_2_aarch64.whl (3.5MiB)
pikepdf-10.5.1-cp311-cp311-musllinux_1_2_x86_64.whl (3.7MiB)
pikepdf-10.5.1-cp311-cp311-win_amd64.whl (3.6MiB)
pikepdf-10.5.1-cp312-cp312-macosx_14_0_arm64.whl (4.6MiB)
pikepdf-10.5.1-cp312-cp312-macosx_15_0_x86_64.whl (4.9MiB)
pikepdf-10.5.1-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (2.4MiB)
pikepdf-10.5.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6MiB)
pikepdf-10.5.1-cp312-cp312-musllinux_1_2_aarch64.whl (3.5MiB)
pikepdf-10.5.1-cp312-cp312-musllinux_1_2_x86_64.whl (3.7MiB)
pikepdf-10.5.1-cp312-cp312-win_amd64.whl (3.6MiB)
pikepdf-10.5.1-cp313-cp313-macosx_14_0_arm64.whl (4.6MiB)
pikepdf-10.5.1-cp313-cp313-macosx_15_0_x86_64.whl (4.9MiB)
pikepdf-10.5.1-cp313-cp313-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (2.4MiB)
pikepdf-10.5.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6MiB)
pikepdf-10.5.1-cp313-cp313-musllinux_1_2_aarch64.whl (3.5MiB)
pikepdf-10.5.1-cp313-cp313-musllinux_1_2_x86_64.whl (3.7MiB)
pikepdf-10.5.1-cp313-cp313-win_amd64.whl (3.6MiB)
pikepdf-10.5.1-cp314-cp314-macosx_14_0_arm64.whl (4.5MiB)
pikepdf-10.5.1-cp314-cp314-macosx_15_0_x86_64.whl (4.9MiB)
pikepdf-10.5.1-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (2.4MiB)
pikepdf-10.5.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (2.6MiB)
pikepdf-10.5.1-cp314-cp314-musllinux_1_2_aarch64.whl (3.5MiB)
pikepdf-10.5.1-cp314-cp314-musllinux_1_2_x86_64.whl (3.7MiB)
pikepdf-10.5.1-cp314-cp314-win_amd64.whl (3.7MiB)
pikepdf-10.5.1.tar.gz (4.4MiB)
Extras:
Dependencies:
Pillow (>=10.0.1)
Deprecated
lxml (>=4.8)
packaging