This is the place of development for a liberal-licensed1 Python PDF rendering library, powered by PDFium.
- CPython >= 3.6 2
Windows
amd64 / arm64 / win32macOS
x86_64 (10.13+) / arm64 (11.0+)Linux (glibc)
x86_64 / i686 / aarch64 / armv7lLinux (musl)
x86_64 / i686 / aarch64Android
arm64_v8a / armeabi_v7a (+ x86_64 / x86 simulators) (experimental)iOS
arm64 (+ arm64 / x86_64 simulators) (experimental, untested)
These are the platforms supported with pre-built binaries. In principle, pypdfium2 may run anywhere provided you are able to procure a pdfium build for the platform.
python3 -m pip install pypdfium2
import pypdfium2 as pdfium
# Load a document
pdf = pdfium.PdfDocument("tests/resources/multipage.pdf")
# Loop over pages and render
for i in range(len(pdf)):
page = pdf[i]
image = page.render(scale=4).to_pil()
image.save(f"output_{i:03d}.jpg")
- Liberal license (
BSD-3-Clause
,Apache-2.0
, plus various other open-source licenses for third-party components of PDFium.) - Wide range of supported platforms and Python versions.
- No mandatory runtime dependencies.
- Can process encrypted (password-protected) PDFs.
- Rendering is fast, outperforming
ghostscript
andpoppler
. In terms of speed, pypdfium2 can almost reachpymupdf
. - Multiple choices for the rendering return type:
- pypdfium2 repository (with support model code)
- pypdfium2 documentation
- ctypes documentation
- pdfium repository
- pdfium merge requests
- pdfium bug tracker
- pdfium mailing list
For pdfium documentation, please look at the comments in its public header files (public/*.h
).
Footnotes
-
Disclaimer: This is not legal advice. While we hope this project is useful to others, there is ABSOLUTELY NO WARRANTY. It is the embedder's responsibility to check on licensing. See also GitHub's disclaimer. ↩
-
PyPy might work but is not tested. ↩