Skip to main content

Read and write PDFs with Python, powered by qpdf

Project description

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”.

Python 3.5 and 3.6 are fully supported.

Features:

  • Editing, manipulation and transformation of existing PDFs

  • Based on the mature, proven QPDF C++ library

  • Reading and writing encrypted PDFs, with all encryption types except public key

  • Supports all PDF compression filters

  • Supports PDF 1.3 through 1.7

  • Can create “fast web view” (linearized) PDFs

  • Creates standards compliant PDFs that pass validation in other tools

  • Automatically repairs damaged PDFs, just like QPDF

  • Can manipulate PDF/A, PDF/X and other types without losing their metadata marker

  • Implements more of the PDF specification than existing Python PDF tools

  • For convenience, renders PDF pages or embedded PDF images in Jupyter notebooks and IPython

# Elegant, Pythonic API
pdf = pikepdf.open('input.pdf')
num_pages = len(pdf.pages)
del pdf.pages[-1]
pdf.save('output.pdf')

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.

Installation

On Unix (Linux, macOS)

Binary wheels are available for x86-64 Linux platforms and Intel macOS. 32-bit wheels will be added if anyone needs them.

  • pip install pikepdf

From source

A C++11 compliant compiler is required, which includes most recent versions of GCC (4.8 and up) and clang (3.3 and up). A C++14 compiler is recommended.

libqpdf 7.0.0 is required at compile time and runtime. Many platforms have not updated to this version, so you may need to install this program without a package manager.

  • clone this repository

  • install libjpeg, zlib and qpdf on your platform, including headers

  • pip install ./pikepdf

On Windows (Requires Visual Studio 2015)

Windows is not currently part of continuous integration, so this might not work.

  • For Python 3.5:

    • clone this repository

    • pip install ./pikepdf

pikepdf requires a C++11 compliant compiler (i.e. Visual Studio 2015 on Windows). Running a regular pip install command will detect the version of the compiler used to build Python and attempt to build the extension with it. We must force the use of Visual Studio 2015.

::
  • clone this repository

  • “%VS140COMNTOOLS%....VCvcvarsall.bat” x64

  • set DISTUTILS_USE_SDK=1

  • set MSSdk=1

  • pip install ./pikepdf

Note that this requires the user building pikepdf to have registry edition rights on the machine, to be able to run the vcvarsall.bat script.

Windows runtime requirements

On Windows, the Visual C++ 2015 redistributable packages are a runtime requirement for this project. It can be found here.

Building the documentation

Documentation for the example project is generated using Sphinx. Sphinx has the ability to automatically inspect the signatures and documentation strings in the extension module to generate beautiful documentation in a variety formats. The following command generates HTML-based reference documentation; for other formats please refer to the Sphinx manual:

  • cd pikepdf/docs

  • make html

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.

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 the license.

The tests/resources/copyright file describes licensing terms for the test suite and the provenance of test resources.

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-0.1.8.tar.gz (972.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pikepdf-0.1.8-cp36-cp36m-manylinux1_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.6m

pikepdf-0.1.8-cp36-cp36m-macosx_10_6_intel.whl (931.2 kB view details)

Uploaded CPython 3.6mmacOS 10.6+ Intel (x86-64, i386)

pikepdf-0.1.8-cp35-cp35m-manylinux1_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.5m

pikepdf-0.1.8-cp35-cp35m-macosx_10_6_intel.whl (931.2 kB view details)

Uploaded CPython 3.5mmacOS 10.6+ Intel (x86-64, i386)

File details

Details for the file pikepdf-0.1.8.tar.gz.

File metadata

  • Download URL: pikepdf-0.1.8.tar.gz
  • Upload date:
  • Size: 972.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pikepdf-0.1.8.tar.gz
Algorithm Hash digest
SHA256 bcdd14abc6647de784693e3a24bc6660abac6b36e870bfd1cfcfb6406aad29ba
MD5 a9d66a7f20925c4460dc5f7eebc3acce
BLAKE2b-256 387eefd51555ee6bb7516f9e7146c50352efd0606f1810bf001880f5361da120

See more details on using hashes here.

File details

Details for the file pikepdf-0.1.8-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pikepdf-0.1.8-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 968f8477fc990ef695c3739cbb6bbe5583f9e620f561c6e51bd0ed6e8bb6c81f
MD5 1ad47a1645dbb85bb3e5edfd624498e1
BLAKE2b-256 6427e523654c962b21497cf09f629f641631c1e05a95ebd843a2ff67ebd37c16

See more details on using hashes here.

File details

Details for the file pikepdf-0.1.8-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pikepdf-0.1.8-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 b5fe503a08ae09be0caa0e7758ed4b23f315aa2aa06d2a5f9a621e56ede2d4d7
MD5 316952462eb3849d703968c33dac02c3
BLAKE2b-256 c1151b25df47030f2bf24ced9ae99cfb8ee4f8784606e71cd03a70b2c82e5bb1

See more details on using hashes here.

File details

Details for the file pikepdf-0.1.8-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pikepdf-0.1.8-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 4add15c91777062c8273ee1589fd4f7a51871751add6531874f23e064c6c8886
MD5 f459e91e014314de9c60ac75518a7236
BLAKE2b-256 95c042b253bf1015a95d23cb9c262b3358aa11a5ac064ee6025982a37269cd03

See more details on using hashes here.

File details

Details for the file pikepdf-0.1.8-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pikepdf-0.1.8-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 39b01fcd17d05656ac3a7a7130f650e853ecbe1023610e747670aa7179e1c009
MD5 0b39fe45cae9b4ae2a4b90b03af9d16c
BLAKE2b-256 09a7e2b5747aed715d0bd97efa5e59d66aae6cea5779fefb1151b793fa0a3da2

See more details on using hashes here.

Supported by

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