Skip to content

Conversation

@dependabot
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Nov 2, 2025

Updates the requirements on pypdfium2 to permit the latest version.

Release notes

Sourced from pypdfium2's releases.

5.0.0

Changes (Release 5.0.0)

Summary (pypdfium2)

API changes

  • Rendering / Bitmap
    • Removed PdfDocument.render() (see deprecation rationale in v4.25 changelog). Instead, use PdfPage.render() with a loop or process pool.
    • Removed PdfBitmap.get_info() and PdfBitmapInfo, which existed mainly on behalf of data transfer with PdfDocument.render(). Instead, take the info from the PdfBitmap object directly. (If using an adapter that copies, you may want to store the relevant info in variables to avoid holding a reference to the original buffer.)
    • PdfBitmap.fill_rect(): Changed argument order. The color parameter now goes first.
    • PdfBitmap.to_numpy(): If the bitmap is single-channel (grayscale), use a 2d shape to avoid needlessly wrapping each pixel value in a list.
    • PdfBitmap.from_pil(): Removed recopy parameter.
  • Pageobjects
    • Renamed PdfObject.get_pos() to .get_bounds().
    • Renamed PdfImage.get_size() to .get_px_size().
    • PdfImage.extract(): Removed fb_render option because it does not fit in this API. If the image's rendered bitmap is desired, use .get_bitmap(render=True) in the first place.
  • PdfDocument.get_toc(): Replaced PdfOutlineItem namedtuple with method-oriented wrapper classes PdfBookmark and PdfDest, so callers may retrieve only the properties they actually need. This is closer to pdfium's original API and exposes the underlying raw objects. Provides signed count as-is rather than splitting in n_kids and is_closed. Also distinguishes between dest is None and a dest with unknown mode.
  • Renamed misleading PdfMatrix.mirror() parameters v, h to invert_x, invert_y, as the terms horizontal/vertical flip commonly refer to the transformation applied, not the axis around which is being flipped (i.e. the previous v meant flipping around the Y axis, which is vertical, but the resulting transform is inverting the X coordinates and thus actually horizontal). No behavior change if you did not use keyword arguments.
  • PdfTextPage.get_text_range(): Removed implicit translation of default calls to .get_text_bounded(), as pdfium reverted FPDFText_GetText() to UCS-2, which resolves the allocation concern. However, callers are encouraged to explicitly use .get_text_bounded() for full Unicode support.
  • Removed legacy version flags V_PYPDFIUM2, V_LIBPDFIUM, V_BUILDNAME, V_PDFIUM_IS_V8, V_LIBPDFIUM_FULL in favor of PYPDFIUM_INFO, PDFIUM_INFO.

Improvements and new features

  • Added PdfPosConv and PdfBitmap.get_posconv(page) helper for bidirectional translation between page and bitmap coordinates.
  • Added PdfObject.get_quad_points() to get the corner points of an image or text object.
  • Exposed PdfPage.flatten() (previously semi-private _flatten()), after having found out how to correctly use it. Added check and updated docs accordingly.
  • With PdfImage.get_bitmap(render=True), added scale_to_original option (defaults to True) to temporarily scale the image to its native pixel size. This should improve output quality and make the API substantially more useful. Thanks to Lei Zhang for the suggestion.
  • Added context manager support to PdfDocument, so it can be used in a with-statement, because opening from a file path binds a file descriptor (usually on the C side), which should be released explicitly, given OS limits.
  • If document loading failed, err_code is now assigned to the PdfiumError instance so callers may programmatically handle the error subtype. This addresses {issue}308.
  • In PdfPage.render(), added a new option maybe_alpha to use a pixel format with alpha channel if page content has transparency, as rendering to a non-alpha bitmap is inefficient with PDFium in this case. Therefore, it is recommended to set this option to True if dynamic (page-dependent) pixel format selection is acceptable. Alternatively, you might want to use only BGRA via force_bitmap_format=pypdfium2.raw.FPDFBitmap_BGRA (at the cost of occupying more memory compared to BGR).
  • In PdfBitmap.new_*() methods, avoid use of .from_raw(), and instead call the constructor directly, as most parameters are already known on the caller side when creating a bitmap.
  • PdfPage.remove_obj() is now aware of objects nested in Form XObjects, and will use the new pdfium API FPDFFormObj_RemoveObject() in that case. Correspondingly, a .container attribute has been added to PdfObject, which points to the parent Form XObject, or None if the object is not nested.
  • In the rendering CLI, added --invert-lightness --exclude-images post-processing options to render with selective lightness inversion. This may be useful to achieve a "dark theme" for light PDFs while preserving different colors, but goes at the cost of performance. (PDFium also provides a color scheme option, but this only allows you to set colors for certain object types, which are then forced on all instances of the type in question. This may flatten different colors into one, leading to a loss of visual information.)
  • Corrected some null pointer checks: we have to use bool(ptr) rather than ptr is None.
  • In PdfDocument.save(), changed default of flags from FPDF_NO_INCREMENTAL to 0, as suggested by an upstream maintainer.
  • Avoid creation of sized pointer types at runtime, to not blow up an unbounded pointer type cache of ctypes, which could effectively lead to a memory leak in a long-running application (i.e. do (type * size).from_address(addressof(first_ptr.contents)) instead of cast(first_ptr, POINTER(type * size)).contents). Thanks to Richard Hundt for the bug report, {issue}346. The root issue (ctypes using an unbounded cache in the first place) has been fixed recently in Python 3.14. See below for a list of APIs that were affected:
    • Anything using _buffer_reader/_buffer_writer under the hood (PdfDocument created from byte stream input, PdfImage.load_jpeg(), PdfDocument.save()).
    • PdfBitmap.from_raw() rsp. PdfBitmap._get_buffer() and their internal callers (PdfBitmap makers new_foreign and new_foreign_simple, PdfImage.get_bitmap()).
    • Also, some Readme snippets were affected, including the raw API rendering example. The Readme has been updated to mention the problem and use .from_address(...) instead.
    • With older versions of pypdfium2/python, periodically calling ctypes._reset_cache() can work around this issue.
  • Improved startup performance by deferring imports of optional dependencies to the point where they are actually needed, to avoid overhead if you do not use them.
  • Simplified version classes (no API change expected).

Platforms

  • Experimental Android (PEP 738) and iOS (PEP 730) support added. Android arm64_v8a, armeabi_v7a, x86_64, x86 and iOS arm64 device and arm64, x86_64 simulators are now handled in setup and should implicitly download the right pdfium-binaries. Provided on a best effort basis, and largely untested. Testers/feedback welcome.
  • pypdfium2's setup is now also capable of producing wheels for these platforms, but they will not actually be included in releases at this time. (Once Termux ships Python 3.13, we may want to publish Android arm64_v8a and maybe armeabi_v7a wheels, but we do not intend to provide wheels for simulators.)
  • iOS will not actually work yet, as the PEP indicates binaries ought to be moved to a special Frameworks location for permission reasons, in which case you'd also have to patch pypdfium2's library search. We cannot do anything about this yet without access to a device or clearer instructions. Community help would be appreciated here.
  • Added draft cibuildwheel workflow and configuration, as a second footing for the project (based on the native sourcebuild, see below). In the future, this may allow to stuff some Linux architecture gaps the quick & dirty way with emulation, or maybe new native runners. Many thanks to wojiushixiaobai for providing the initial workflow and helpful pointers.

Setup

... (truncated)

Commits
  • 5ab1b3c [autorelease main] update 5.0.0
  • 6e2b804 workflows/trigger_main.yaml: fix dispatch
  • 7beb515 Clean up weird inconsistency in PdfPage.get_objects() code
  • 814ab5b PdfPage.render() docs: fix an oversight
  • 8bfd58e Fix windows cross-compilation targets (closes #382)
  • baedbdf Attempt to fix windows sourcebuild
  • e4acf83 Comment cleanups
  • 6ba3e07 Issue template nits
  • ebde88f Readme: add another individual to Thanks section
  • 3ae2758 build_native: add full explanation for siso.patch case
  • Additional commits viewable in compare view

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Updates the requirements on [pypdfium2](https://github.com/pypdfium2-team/pypdfium2) to permit the latest version.
- [Release notes](https://github.com/pypdfium2-team/pypdfium2/releases)
- [Commits](pypdfium2-team/pypdfium2@4.11.0...5.0.0)

---
updated-dependencies:
- dependency-name: pypdfium2
  dependency-version: 5.0.0
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added the topic: build Related to dependencies and build label Nov 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: build Related to dependencies and build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant