pikepdf is a Python library that enables reading, writing, repairing, and transforming PDF files, leveraging the powerful `qpdf` C++ library. It offers comprehensive PDF manipulation capabilities, including merging, splitting, compressing, and extracting data. Currently at version 10.5.1, it follows a regular release cadence with several minor and patch releases per year.
pip install pikepdfVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to create a new PDF, add pages to it, and then open and modify an existing PDF file using `pikepdf`. The `Pdf` object should always be used within a `with` statement for proper resource management.
Install `qpdf` via your system's package manager (e.g., `apt install qpdf` on Debian/Ubuntu, `brew install qpdf` on macOS, or download from qpdf.sourceforge.io for Windows).
Replace `Pdf.read(filename)` with `with Pdf.open(filename) as pdf:`.
When accessing page box coordinates, adapt your code from `box[0]` to `box.as_list()[0]` or use `box.left`, `box.bottom`, etc. directly on the `PageBox` object.
Ensure `pdf.save(output_filename)` is called after all modifications. When using `with Pdf.open(...) as pdf:`, `pdf.save()` should be called within the `with` block.
pip install pikepdf
Ensure you have a C++ compiler (e.g., Visual Studio Build Tools on Windows, Xcode Command Line Tools on macOS, `build-essential` on Debian/Ubuntu) and the 'qpdf' development libraries installed on your system. For macOS, `brew install qpdf` is often required before `pip install pikepdf`.
Provide the correct password as an argument to the `open` method: `pdf = pikepdf.Pdf.open('input.pdf', password='your_password')`.Update the method call to `pdf.check_pdf_syntax()`: `messages = pdf.check_pdf_syntax()`.
First, try installing a pre-built wheel if available: `pip install --force-reinstall pikepdf`. If building from source is necessary, ensure your C++ compiler matches the one used to build Python and `qpdf`, and that all necessary `qpdf` libraries and headers are accessible to the compiler and linker. On Windows, ensure the correct Visual C++ Redistributable is installed.
No dependency data recorded yet.