This is the place of development for a liberal-licensed Python PDF rendering library, powered by PDFium.
- CPython >= 3.6 1
Windows
amd64 / arm64 / win32macOS
x86_64 (10.13+) / arm64 (11.0+)Linux (glibc)
x86_64 / i686 / aarch64 / armv7lLinux (musl)
x86_64 / i686 / aarch64
(as of Mar 2023)
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
-
PyPy might work but is not tested. ↩