pypi / pypdfium2
pypdfium2
What changed in pypdfium2 4 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.
40 breaking5 security3 deprecations50 new APIs and options3 performance19 behavior and defaults6 tooling41 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli initpypdfium2 5162 changes
Breaking changes 37
Open, three-sided paths are no longer recognized as rectangles.
Module splitting through PYPDFIUM_MODULES={raw,helpers} is dropped; downstream packagers needing module splitting are advised to patch the project name and module include rules.
The project no longer provides its own conda packaging; the notes say pypdfium2 can instead be installed from PyPI in a conda environment.
The system-generate target is dropped.
Python versions below 3.8 are broken, so developers need Python 3.8 or newer.
The minimum macOS requirement for packaging is now 12.0.
The transitional --no-legacy-gn option has been removed; recent GN is now required.
Formenv lifetime is managed through PdfDocument; close_forms() replaces PdfFormEnv.close().
The parent alias has been removed from PdfFormEnv.
The pdf attribute has been removed; callers should access their PdfDocument object directly.
PdfPage.parent now always points to a PdfDocument rather than sometimes pointing to a PdfFormEnv.
For pages registered as kids of a formenv, parent now points at the formenv and should be treated purely as an autoclose hook.
Raises a meaningful exception when the required textpage is missing.
The setting moved from pypdfium2 to pypdfium2_cfg, which can be imported before pypdfium2 for init-time configuration.
The CLI moved from pypdfium2._cli to its own submodule, with a module invocation and entrypoint available there.
Opening password-protected PDFs is broken on s390x; the release notes describe this platform as use at own risk.
Removed the --use-syslibs option; use build_native instead.
Renamed from sourcebuild.py; the toolchained build script remains available.
The color parameter now comes first, so positional calls may need updating.
The recopy parameter was removed.
Removed; retrieve bitmap information directly from the PdfBitmap object.
Single-channel grayscale bitmaps now use a 2D shape rather than wrapping each pixel value in a list.
Removed; retrieve bitmap information directly from the PdfBitmap object.
Replaced PdfOutlineItem namedtuples with PdfBookmark and PdfDest wrappers, exposing underlying raw objects and distinguishing absent destinations from destinations with unknown mode.
Removed; use PdfPage.render with a loop or process pool instead.
The default flags value changed from FPDF_NO_INCREMENTAL to 0.
Removed the fb_render option; use get_bitmap(render=True) when the rendered bitmap is desired.
Renamed from PdfImage.get_size.
Renamed to PdfImage.get_px_size.
Renamed from PdfObject.get_pos.
Renamed to PdfObject.get_bounds.
Default calls no longer translate implicitly to get_text_bounded; callers are encouraged to use get_text_bounded explicitly for full Unicode support.
Introduced as a replacement for the legacy version flags.
Renamed to build_toolchained.py.
Removed along with the legacy version flags; use PYPDFIUM_INFO or PDFIUM_INFO instead.
Removed along with the legacy version flags; use PDFIUM_INFO instead.
Removed along with the legacy version flags; use PYPDFIUM_INFO instead.
Security 5
Avoids integer overflows while decoding Fax G4 rows.
Updated the bundled PDFium from 8076 to 8146, including fixes for a few CVEs. The notes still advise against exposing pypdfium2 to untrusted input in an unsandboxed environment.
The native sourcebuild includes a cherry-picked OpenJPEG security fix for CVE-2026-6192.
A patch addressing CVE-2025-54874 was cherry-picked into OpenJPEG.
Added --verify to require checking the build attestation; verification is enabled automatically if the gh dependency is installed.
Deprecations 3
Closing foreign bitmaps now warns that the operation may be unsafe because it frees the C-side buffer.
PdfFormEnv.close() is deprecated and is now a no-op; use PdfDocument.close_forms() instead.
The CLI moved to pypdfium2_cli; use pypdfium2_cli.__main__, python3 -m pypdfium2_cli, or the pypdfium2 entrypoint instead.
New APIs and options 49
Adds an API that returns a structure element’s raw type.
Adds an API to read attachment descriptions.
Adds an API to obtain an attachment's MIME type.
Adds an API to write attachment descriptions.
Set warn_on_close to False to silence the warning when you have made sure closing a foreign bitmap is safe.
Adds an API to retrieve bookmark style.
Adds the PdfBookmarkStyle binding.
PDFium adds APIs to read and write attachment descriptions.
The public FormFill API exposes SetTextDirection, allowing integrations to set text direction.
Experimental Pyodide build support was added. Builds are flaky, may crash or freeze on shutdown, and are available for download from GitHub but not PyPI.
Adds a helper to retrieve a bookmark's color, based on PDFium's FPDFBookmark_GetColor API. It is also integrated into the pypdfium2 toc CLI; the API is not yet available to conda users.
In PORTABLE_MODE, build_toolchained.py can now use clang by passing --clang-path.
The PDFium version can now be configured in cibuildwheel configuration and workflows.
On Linux with glibc, build_native.py can use a sysroot; the current cibuildwheel configuration opts in with USE_SYSROOT=1.
build_native.py accepts --no-legacy-gn to skip legacy GN patches; the option is opt-in for now.
Adds a default-font diagnostic CLI command.
Allows view_pos to be provided as a tuple.
Exposes a helper for PDFium’s default TTF map.
Adds a decoding errors option that defaults to replace.
Adds a helper for loading standard fonts.
Adds the standard-fonts helper.
Adds a textpage passthrough parameter, required for PdfTextObj.extract().
Adds a font diagnostic CLI command.
Added a property for checking whether a PDF font is embedded.
PDFIUM_INFO is now available from within pypdfium2_raw after version information was split into pypdfium2_raw/version.py.
Added a Warning subclass that is issued when XFA form loading fails, providing programmatic error code information instead of only a log message.
This helper wraps FPDF_SYSFONTINFO and related APIs; callers can subclass it to inspect or alter how PDFium uses system fonts.
Added a stub submodule that can be imported before pypdfium2 for init-time configuration; DEBUG_AUTOCLOSE moved to this module.
Saving PDFs can now subset newly embedded fonts, including their width arrays and ToUnicode streams.
Adds an option to build with clang while presenting it to pdfium's build system as gcc; this mode is used to build for s390x with static clang.
Windows-only members are now included in bindings where applicable. Cast an HDC object to pypdfium2.raw.HDC before passing it to FPDF_RenderPage() to ensure compatible types.
Added an option to build_native to disable the libclang_rt dependency.
Added a font helper; the new helpers currently cover font info and object-level text extraction.
Added a text-object helper that currently covers font info and object-level text extraction.
Added a helper for object-level text extraction and font information.
Experimental Android platform support was added for setup and implicit pdfium-binaries downloads on the listed architectures.
Added an environment variable to manually set the full version for other targets.
Added an environment variable to skip the full version for other targets.
Experimental iOS platform handling was added, but iOS will not work yet because library search and binary placement need further changes.
Added context manager support so documents can be used in a with-statement and file descriptors can be explicitly released.
Added scale_to_original, defaulting to True, to temporarily scale a rendered image bitmap to its native pixel size for improved output quality.
Setup now exposes its targets through PDFIUM_PLATFORM, including fallback, system-search, and build-native; uncovered hosts search for system or LibreOffice pdfium before building natively.
Renamed parameters v and h to invert_x and invert_y; behavior is unchanged for callers not using keyword arguments.
Added a container attribute pointing to the parent Form XObject, or None when the object is not nested.
Added to retrieve the corner points of an image or text object.
Added maybe_alpha to use a pixel format with an alpha channel when page content has transparency; setting it to True is recommended when dynamic pixel-format selection is acceptable.
Added a helper for bidirectional translation between page and bitmap coordinates.
Added post-processing options for selective lightness inversion while excluding images, useful for dark themes but with a performance cost.
Embedders can optionally override the selection of SkFontMgr.
Performance 3
Cherry-picked OpenJPEG changes speed up JPEG2000 decoding on arm.
Calls
page.get_bbox()only when at least one boundary value is None, avoiding extra overhead when all bounds are given.The --reset option now uses git restore . rather than git reset --hard, which may be significantly more efficient.
Behavior and default changes 18
CFX_Face supports bare CFF fonts via Skrifa.
CFX_Face supports non-Unicode SFNT charmaps via Skrifa.
Popup appearances are generated only when a popup is opened, changing when that work occurs.
Release wheels use the prefer-sbuild strategy and do not use pdfium-binaries in this release, which may matter when deciding how the wheel obtains PDFium.
The bundled PDFium adds BrotliDecode filter support for PDF 2.0 streams, allowing pypdfium2 users to handle documents using that filter.
For clang versions older than 22, --clang-as-gcc mode is now implicitly enabled.
The riscv64 wheel's glibc requirement was lowered to 2.34 using upstream's sysroot.
The native sourcebuild was updated from PDFium 7191 to 7841, changing the PDFium code used to build the native library.
Objects remove themselves from their parent’s kids cache on garbage collection or closing, and a global ObjectTracker tracks objects by type. This may allow destroying and re-initializing the library during a session.
Now holds a loglevel instead of a bool, distinguishing noisy debug messages from warnings; its default is logging.WARNING.
Added full dependency library vendoring abilities, now the default behavior on fallback setup.
For FPDF_PAGEOBJ_TEXT objects, the constructor now returns PdfTextObj rather than just PdfObject instances.
For FPDF_PAGEOBJ_TEXT objects, now returns PdfTextObj instances rather than just PdfObject instances.
Setup triggers the native build script when a host platform lacks pdfium-binaries and system/LibreOffice pdfium.
Implicit downloads during setup or emplace.py now pin the pdfium version by default, preventing possible API breakage for source installations; update.py and craft.py still default to the latest version.
Document-loading failures now assign err_code to the PdfiumError instance, enabling programmatic handling of the error subtype.
Exposed the previously semi-private flatten method.
Now handles objects nested in Form XObjects using the new pdfium API.
Tooling 6
Setup handles pdfium-binaries for musllinux_armv7l, and this release includes a CIBW build for that platform.
pypdfium2's build configuration and workflows use gn-dist instead of outdated distro packages of GN.
GCC builds now declare a custom toolchain with environment passthrough; CC, CXX, and TOOLPREFIX can select a compatible compiler, and extra compiler and linker flags are honored.
Added release builds for Android arm64_v8a and armeabi_v7a, ppc64le, riscv64, loongarch64, musllinux_armv7l, and s390x; Loongarch is uploaded to GitHub only.
Significant portability enhancements allow use on Linux CPUs that are unhandled or incomplete upstream, may allow native Windows arm64 builds, and add ppc64le cross-compilation from x86_64.
Added a build script that uses system tools and libraries instead of Google's toolchain; GCC is used by default, and Clang should also work with symlinks configured.
Fixes and other changes 41
Fixes closing on interpreter shutdown, which was broken in the previous release.
Prevents object trackers from being modified while traversed, adding protection to closing machinery.
Fixed a float-cast overflow in DrawPath().
Fixed handling of read failures in ReadStream().
Text-page processing now ignores non-finite page objects.
Added handling for a zero-length gradient axis.
FPDF_GetNamedDest() now dereferences old-style named destinations correctly.
Fixed an incorrect PDF major version in the save header.
For PdfDocument and PdfImage.load_jpeg(), a short readinto() now indicates an error when it reads fewer bytes than the buffer size.
Closing or finalizing a bitmap now always calls FPDFBitmap_Destroy(), including for bitmaps created from a native, pdfium-external buffer.
Fixes an off-by-one error that chopped one byte too much from the document identifier.
Windows spoof headers are now included in source distributions, preventing subtly incorrect bindings when installing from an sdist on Windows.
pdfium-binaries builds are now available for mipsle, expanding the architectures developers can use.
Runtime support and source installation compatibility with Python 3.6 and 3.7 were fixed; ctypesgen continues to require Python >=3.8.
PDFium partially fixes RTL character and line reading order in CPDF_TextPage, affecting text extraction from PDFs.
Fixes a missing mkdir call, particularly for the PDFIUM_PLATFORM=system-search / fallback setup.
Adds MIPS 64-bit and 32-bit little-endian wheels to the release on GitHub. PyPI does not accept these wheels, and pip rejects them unless they are locally re-tagged.
Object ordering from FPDFPage_InsertObjectAtIndex() is now preserved when saving.
Adds error checks to rotation retrieval.
Adds error checks to object insertion.
Adds error checks during setup.
Fixes warnings being shown by removing an incorrect logging.captureWarnings(True); warnings.simplefilter("always") is used instead.
Fixed a regression in loose character-box results introduced in the previous release.
The CLI no longer imports
pypdfium2.__init__before preparation, restoring the intended initialization order.On FreeBSD with libreoffice-pdfium, implicit dependency libraries are pre-loaded with mode=RTLD_GLOBAL to fix library loading.
Input filepaths are encoded as UTF-8 with surrogateescape except on Windows, fixing loading some garbled filenames that previously raised UnicodeEncodeError.
When --test is given, the command now honors the unittests' return code and suppresses a musl-specific failure.
Prevents an infinite loop in AGG when processing degenerate dash patterns.
Fixes reading refine-several symbols in Huffman symbol dictionaries using refinement.
Checks that the bitmap format remains the same before and after progressive rendering.
Fixes shared form XObjects mutating matrix values, preventing unintended changes to shared state during PDF processing.
Fixes text rendering with the wrong x scale when using Skia.
pypdfium2's conda builds now support the ppc64le (glibc) platform.
Fixed handling of odd-sized dashed line arrays in Skia and AGG rendering.
Fixed handling of
discard_transparencyin PNG encoding.Fixed compatibility with Python 3.6 and 3.7.
Fixed decoding of JBIG2 files with more than four referred-to segments and progressive unoptimized decoding of a generic region with template 1.
Rolled the musllinux tag back from 1_2 to 1_1; the pdfium-binaries still run on musllinux_1_1.
Fixed a return value error in the JavaScript document getAnnots method.
Incremental saving now works correctly for edited documents.
Selecting replaced text after undo is fixed.
pypdfium2 45 changes
Breaking changes 3
The raw API bindings are isolated in the pypdfium2.raw namespace.
Raw API bindings no longer implicitly encode strings, which may require changes to code that relied on implicit string encoding.
The support model was fully rewritten, changing many existing features and adding helpers; developers should read the updated documentation to migrate their code.
New APIs and options 1
A consecutive option was added to textpage.
Behavior and default changes 1
Helper objects automatically resolve to the underlying raw object when used as a ctypes function parameter.