Skip to main content

Read and write PDFs with Python, powered by qpdf

Project description

pikepdf is a Python library allowing creation, manipulation and repair of PDF files. It is provides a wrapper around QPDF.

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

This package is in pre-alpha.

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

  • Can read and write PDFs with any type of PDF encryption (except public key)

  • Supports all PDF compression filters

  • Supports PDF object streams

  • Supports PDF 1.3 through 1.7

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

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

  • Automatically recovers and repairs damaged PDFs

  • 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

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, and requires some knowledge of the PDF specification.

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 ./python_example

Note that this requires the user building python_example 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

About Python 2.7

The author’s priority is building a great PDF library for Python for future applications, which means there isn’t time to target Python 2.7. Currently the C++ source compiles and links correctly, so all that is necessary is backporting Python 3 source files.

It was recently confirmed that the C++ code base compiles and links with Python 2.7. One would need to backport the Python source files and fix any test suite regressions. Pull requests are welcome.

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.1rc5.tar.gz (961.0 kB view details)

Uploaded Source

Built Distributions

pikepdf-0.1rc5-cp36-cp36m-manylinux1_x86_64.whl (5.9 MB view details)

Uploaded CPython 3.6m

pikepdf-0.1rc5-cp36-cp36m-macosx_10_6_intel.whl (868.1 kB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

pikepdf-0.1rc5-cp35-cp35m-manylinux1_x86_64.whl (5.9 MB view details)

Uploaded CPython 3.5m

pikepdf-0.1rc5-cp35-cp35m-macosx_10_6_intel.whl (868.1 kB view details)

Uploaded CPython 3.5m macOS 10.6+ intel

File details

Details for the file pikepdf-0.1rc5.tar.gz.

File metadata

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

File hashes

Hashes for pikepdf-0.1rc5.tar.gz
Algorithm Hash digest
SHA256 82e3115b6d254ccac13b2246c8528d88930efb467b1add9d121f6c32e346863c
MD5 423f46e9fa37254b6c3e34df49bdce17
BLAKE2b-256 4603c39d3c14fb89b671a520825ec85f6d02bc475287ea3ae4ea8478bff3711b

See more details on using hashes here.

File details

Details for the file pikepdf-0.1rc5-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pikepdf-0.1rc5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 721b4ec46c52a99a5b9ac32e891da04b6b0acfc7ce43b8960fae775d640bf919
MD5 5fecfdeaf8f2b1533662da821ce2f0cc
BLAKE2b-256 8e56824f52894b6660a4f47377fdc480528303a38614bc644c19e0b2868cde78

See more details on using hashes here.

File details

Details for the file pikepdf-0.1rc5-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pikepdf-0.1rc5-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 2429513ef3511c1f6cadc97b19d975310adc40d6b33b1672e2ced9bc692950f0
MD5 c1a71c5770312288fe40d735b821e3b9
BLAKE2b-256 a5759c3d5a18b9b62f291c67da4f78382fb885b19f16881f4a8bbd8ad8c6d37b

See more details on using hashes here.

File details

Details for the file pikepdf-0.1rc5-cp35-cp35m-manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pikepdf-0.1rc5-cp35-cp35m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 9f0df3aaf9911c06a6018266dcf5ab9c318580140048a36a8993c97e9de612d8
MD5 00af6ab0ce783161eb52b3c22f798511
BLAKE2b-256 84480c044a2a78ef5d6f154d708a282fc01bbdfbf574b412c85c29543e2c4d83

See more details on using hashes here.

File details

Details for the file pikepdf-0.1rc5-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

File hashes

Hashes for pikepdf-0.1rc5-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 1241a99ad6fa25fbac7a49b21de72d5f15a7409f41efd28fb552f7524ddc27bb
MD5 205760f38e9970cc098da237cc15d3b2
BLAKE2b-256 3a6488c3ab666bb247e7a255d20abfdb03d2d7ba2fbf56d60a76c15775a3abf7

See more details on using hashes here.

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