Skip to content

chore(deps): update dependency pikepdf to v10 - #571

Open
renovate[bot] wants to merge 1 commit into
mainfrom
renovate/pikepdf-10.x
Open

renovate[bot] wants to merge 1 commit into
mainfrom
renovate/pikepdf-10.x

Conversation

@renovate

@renovate renovate Bot commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Note

This PR body was truncated due to platform limits.

This PR contains the following updates:

Package Change Age Confidence
pikepdf (changelog) 9.8.1 → 10.18.3 age confidence

Release Notes

pikepdf/pikepdf (pikepdf)

v10.18.3

Compare Source

  • {func}pikepdf.pdfa.check now predicts the right stream filters with
    qpdf versions newer than 12.4.2. Those versions keep the compressed data of a
    stream whose /Filter is the one-element array [/FlateDecode] instead of
    recompressing it. qpdf 12.4.2 recompressed such streams, which removed any
    predictor and could make scanned images larger. {issue}qpdf/qpdf#1785

v10.18.2

Compare Source

  • Fixed crashes on Windows in code that locks more than one Pdf at once,
    such as Pdf.add_pages_from() and signature stamping. Two unrelated internal
    C++ classes had the same name, which broke the one-definition rule. The MSVC
    linker then gave both classes the destructor of one of them. Free-threaded
    (cp314t) Windows wheels, which were left out of v10.18.0 because of these
    crashes, are provided again. {issue}757
  • The extension module is now built with link-time optimization, which makes
    it about 14% smaller. Source builds use it where the toolchain supports it.
    To build without it, pass -C cmake.define.PIKEPDF_LTO=OFF.

v10.18.1

Compare Source

  • Assigning None into a page list, with pdf.pages.extend(), slice
    assignment or pdf.pages[i] = None, now raises the usual "only pikepdf
    pages" TypeError. When pikepdf was built with nanobind older than 2.13, as
    some Linux distributions do, an iterator containing None could instead be
    silently discarded without inserting any pages, or a misleading "incompatible
    function arguments" error was raised. {pr}759
  • pikepdf now requires nanobind 2.5.0 or newer to build, and is tested against
    it.

v10.18.0

Compare Source

  • {meth}pikepdf.Pdf.add_pages_from now carries layers (optional content) with
    the pages it copies. The optional content groups that the copied pages
    depend on are listed in the destination's /OCProperties, with the default
    visibility, place in the layer list, lock, radio button groups and automatic
    states that the source's default configuration gave them. Previously the
    groups were copied but not listed, so viewers ignored them: the layer list
    was empty and content hidden in the source was shown. {issue}118
  • {meth}pikepdf.Pdf.add_pages_from now carries bookmarks. Outline items of
    the source that lead to a copied page are appended to the destination's
    outline, keeping their hierarchy, titles and style; items that lead to pages
    that were not copied are dropped. {issue}281
  • Both are on by default, which changes what existing callers of
    add_pages_from get: the destination may gain an /OCProperties and
    outline items it did not gain before. Pass layers='ignore' or
    outlines='ignore' for the previous behaviour, for example if you build
    the merged outline yourself. {class}pikepdf.PageCopyResult reports
    layers_added, outline_items_added and outline_items_dropped.
  • {meth}pikepdf.Pdf.check_pdf_syntax now performs the same checks as
    qpdf --check and reports the same problems. It checks the linearization
    data and hint tables of linearized files, which previously required a
    separate call to {meth}pikepdf.Pdf.check_linearization, and checks the
    interactive form, embedded files, page labels and outlines. A document with
    no pages is reported as ERROR: file does not contain any pages, and a page
    whose content stream cannot be read is reported as ERROR: page N: ...
    along with the other problems found, where it previously raised
    {class}pikepdf.PdfError. {issue}515
  • Inserting a {class}pikepdf.Dictionary or {class}pikepdf.Array that
    refers to another Pdf into a Pdf now raises
    {exc}pikepdf.ForeignObjectError, naming the key or index where the
    foreign object was found, and leaves the target unchanged. This covers an
    indirect object of another Pdf held anywhere in the value, such as
    pdf3.Root.X = Dictionary(P=pdf1.Root.Y), and a direct dictionary or array
    that another Pdf already contains. Previously the value was accepted:
    the first kind made the Pdf impossible to save, failing part way through
    writing, and the second left two documents sharing one object. It applies
    to every way of inserting a value, including {meth}pikepdf.Pdf.make_indirect,
    {meth}pikepdf.Page.add_resource, adding a page built from a dictionary,
    name and number trees, and stream dictionaries. Use
    {meth}pikepdf.Pdf.copy_foreign to bring the foreign object over first.
  • A password containing a NUL character now raises {exc}ValueError, both
    when opening a PDF and when encrypting one. Previously the password was
    silently cut short at the NUL, so a wrong password could open a file, and an
    encrypted file could be written with a shorter password than requested.
    PDF passwords may not contain NUL. {issue}756
  • Fixed threads interfering with each other inside one Pdf on GIL-enabled
    builds, which could cause an object to be read as None. The per-Pdf lock
    is now in force on every build, and {meth}pikepdf.Pdf.lock works on
    GIL-enabled builds too. {commit}7c761d23
  • Methods implemented in Python that change a Pdf in several steps, such as
    {meth}pikepdf.Page.add_overlay, {meth}pikepdf.Pdf.add_pages_from and
    the {mod}pikepdf.sanitize functions, now hold its lock until they finish.
    The thread safety section of the architecture notes now says which calls are
    atomic. {commit}0872a6e8, {commit}b10671c3
  • Two threads that each hold the lock of one Pdf and then need the other's
    no longer deadlock; one of them gets a {exc}RuntimeError instead. What a
    callback such as a {class}pikepdf.TokenFilter may do is now documented:
    see {ref}callback-restrictions. {commit}11ef776b
  • Fixed a crash, a native stack overflow that no Python except can catch,
    when reading, saving or checking a PDF in which a JBIG2 image's
    /JBIG2Globals stream is itself JBIG2-encoded and leads back to the image,
    directly or through other streams. Such an image is now reported as
    unfilterable, as JBIG2-encoded globals without a cycle already were:
    reading it raises {exc}~pikepdf.exceptions.PdfError, extracting it raises
    {exc}~pikepdf.exceptions.UnsupportedImageTypeError, and saving writes it
    unchanged with a warning. {issue}753
  • A JBIG2 image's /JBIG2Globals are now read only when the image is being
    JBIG2-decoded, rather than every time qpdf checks whether the image can be
    decoded, which included every save.
  • Reading the label of a page whose page label style is an unknown name, such
    as /S /Z, now warns and keeps the label prefix, as an invalid non-name
    style already did. Previously it raised KeyError.
  • Reading the label of a page whose number cannot be written in its page
    label style, such as /S /R /St 0 or a Roman numeral above 5000, now warns
    and writes the number in decimal digits. Previously it raised ValueError.
  • Extracting an image whose /CalGray or /CalRGB colour space array lacks
    its parameter dictionary now decodes it as the corresponding device space,
    without an ICC profile, as a missing /WhitePoint already did. Previously
    it raised IndexError.
  • An ICCBased image whose profile stream omits the required /N, or gives
    one that is not an integer, now takes its mode and default /Decode from
    the profile's colour space. Previously its mode raised KeyError.
  • Fixed {meth}pikepdf.form.SignatureField.stamp_overlay stamping the
    overlay twice when the signature widget names its page with /P.
  • Fixed a Pdf returned by {meth}pikepdf.Job.create_pdf not being set up
    like other Pdf objects: setting its conversion_mode raised
    {class}pikepdf.PdfError, and on free-threaded Python none of its methods
    were protected by a lock.
  • Matrix.__array__(copy=False) now raises ValueError, as numpy expects of
    an object that cannot share its memory. The check for this was written in a
    way that never fired.
  • A progress argument to {meth}pikepdf.Pdf.save that is not callable is
    now rejected with TypeError before anything is written. Previously the
    error was raised part of the way through writing the file.
  • Fixed a small memory leak each time
    {meth}pikepdf.AcroForm.get_fields_with_qualified_name or
    {meth}pikepdf.AcroForm.fix_copied_annotations returned a field.
  • Iterating over a {class}pikepdf.NameTree or {class}pikepdf.NumberTree
    now iterates over the keys it had when the iteration began. Previously the
    tree was read as the iteration went on, so changing it meanwhile gave
    undefined results.
  • Putting an object that belongs to another Pdf in a
    {class}pikepdf.NameTree or {class}pikepdf.NumberTree now raises
    {class}pikepdf.ForeignObjectError at once, as it does for a dictionary or
    an array. Previously the error was not raised until the Pdf was saved.
  • x in tree is now False for an x that cannot be a key of a
    {class}pikepdf.NameTree, such as an int, and for None in a
    {class}pikepdf.NumberTree. Previously these raised TypeError.
  • Corrected the documentation and type hints of {class}pikepdf.NameTree,
    which said that names are bytes. Names are, and have always been, str:
    qpdf reads each name as a PDF text string and compares names by that text.
  • Fixed building from source on Android (Termux), where importing pikepdf
    failed with cannot locate symbol "_Py_TrueStruct" since v10.6.0. The
    extension module is now linked against libpython when the build interpreter
    is an Android Python, as that platform requires. Android is not a tested
    platform. {issue}752
Free-threaded Python fixes

Many crashes and data races that occurred when several threads used the same
Pdf at once have been fixed. The test suite now runs under ThreadSanitizer
in continuous integration, which is how most of them were found
({commit}4831f6fc).

  • Every binding that reads or changes a Pdf now takes that Pdf's lock,
    and the lock of any other Pdf among its arguments, enforced at compile
    time. Many bindings previously did not, notably most methods of
    {class}pikepdf.NameTree, {class}pikepdf.NumberTree, attachments,
    annotations and {class}pikepdf.AcroForm. {commit}3c5b2bc4
  • Fixed crashes and data races in {class}pikepdf.Page methods, content
    stream parsing, adding pages from one Pdf to another, and dropping the
    last reference to a Pdf while another thread used one of its objects.
    {commit}04999faf
  • A {class}pikepdf.Dictionary or {class}pikepdf.Array that belongs to no
    Pdf is now protected by a lock shared by all such objects. Threads that
    each build objects of their own contend for it, so add a Dictionary or
    Array to its Pdf as soon as it is created rather than building large
    structures before adding them. {commit}5e11a240, {commit}b10671c3
  • Fixed "dictionary changed size during iteration" when several threads
    opened a Pdf's metadata for the first time at once. {commit}d52a9a11
  • Threads that take turns using the same Pdf are no longer slowed to a
    crawl when every CPU is busy. {commit}a3e2b882

Free-threaded wheels are not provided for Windows in this release. They crash
in the test suite, for reasons that have not yet been found, so free-threaded
Python on Windows is not supported for now. Linux and macOS free-threaded
wheels are provided as before. {issue}757

v10.17.0

Compare Source

  • Added {class}pikepdf.ObjectSet, which records the objects that a walk of
    a PDF's object graph has already visited. Objects in a PDF are shared and
    may refer back to their ancestors, so a search that only limits its depth
    can take exponential time on quite ordinary files. ObjectSet.add() reports
    whether an object is new, and tells apart direct objects and objects of
    different Pdf, which a set of objgen cannot. See
    {ref}walking-object-graphs.
  • Added {meth}pikepdf.Object.is_same_object_as, which tests whether two
    references lead to the same object. Neither is, == nor comparing
    objgen answers this reliably.
  • Added {meth}pikepdf.Pdf.content_scopes and
    {meth}pikepdf.Page.content_scopes, which iterate over every content stream
    that pages can draw, each with the resource dictionary it uses: the page
    itself, form XObjects, annotation appearance streams, tiling patterns,
    Type 3 glyph procedures and soft masks, however they are nested or shared.
    This is the way to find every font, image or colour space a document uses.
    Each {class}pikepdf.ContentScope is reported once for the document;
    pages= selects pages and kinds= selects what is reported.
  • Added {meth}pikepdf.Page.get_resources, which returns the resources of a
    page or form XObject for reading. Unlike {attr}pikepdf.Page.resources, it
    finds resources inherited from the page tree, does not create an empty
    dictionary when there are none, and returns None instead of raising when
    /Resources is malformed.
  • Fixed comparing two objects with == taking exponential time when the
    objects being compared share children, such as the same file opened twice.
    Each pair of objects is now compared once.
  • Fixed {meth}pikepdf.Pdf.add_pages_from hanging on a page with an action
    whose /Next actions are shared or form a loop.
  • Fixed {meth}pikepdf.Pdf.open_outline reading only the first item at each
    level of an outline whose items are direct objects. Such items are now made
    indirect when the outline is saved, as the PDF specification requires.
  • Reading a stream that will not decode now raises
    {exc}~pikepdf.exceptions.DataDecodingError with the reason, whether the
    stream's data was read from a file or set from memory. Previously a stream
    read from a file raised a {exc}~pikepdf.exceptions.PdfError that said only
    "read_bytes called on unfilterable stream", and the reason was available
    only from {meth}pikepdf.Pdf.get_warnings. DataDecodingError is a
    PdfError, so existing handlers are unaffected. {issue}182
  • An exception raised by a JBIG2 decoder now reaches the caller of
    {meth}pikepdf.PdfImage.as_pil_image, {meth}pikepdf.PdfImage.extract_to
    and {meth}pikepdf.PdfImage.read_bytes unchanged, with its own type,
    message and traceback. Previously, for an image read from a file, it was
    replaced by a generic DataDecodingError or PdfError. {issue}182
  • Added {exc}~pikepdf.exceptions.QpdfRuntimeError, raised for errors from
    qpdf that pikepdf has no more specific exception for. These were previously
    raised as a bare RuntimeError, which except pikepdf.PikepdfError did not
    catch. The new exception derives from both
    {exc}~pikepdf.exceptions.PikepdfError and RuntimeError, so handlers
    written for RuntimeError still work. {issue}240
  • The empty name / is now supported. The PDF 1.7 and 2.0 specifications
    define a lone slash as a valid name made of zero characters, but
    pikepdf.Name('/') raised ValueError, and dictionaries refused / as a
    key. This broke {meth}pikepdf.Pdf.add_pages_from on files
    with an empty-named destination such as /Dests << / 3 0 R >>. Such names
    can now be created, used as dictionary keys, and migrated during page
    copying. bool(Name('/')) is False, like an empty {class}pikepdf.String.
    Name(''), which lacks the leading slash, is still rejected. PDF/A does not
    forbid empty names, and the PDF/A validator accepts them. Thanks to
    @​sjudd for the report and @​DSeaStar for the analysis. {issue}745
  • AcroFormField.get_inheritable_field_value_as_name() now returns a
    {class}pikepdf.Name, as documented, instead of a str. When the value is
    missing or not a name, it returns the empty name Name('/'), which is falsy,
    instead of ''. Comparisons such as == '/Tx' are unaffected. {issue}748
  • Fixed an out-of-bounds read when opening a PDF from a Python file object
    whose readinto() reports more bytes than were requested. This now raises
    ValueError, as writing to such a stream already did. Non-blocking streams,
    whose readinto() returns None, now raise ValueError instead of hanging.
    Thanks to @​Nayana-Naik73. {issue}747
  • Fixed building from source on PyPy, which failed to compile since v10.0.
    PyPy now reads Python file objects through readinto(), like CPython,
    instead of copying the result of read().
  • {func}pikepdf.open reads directly from the file descriptor when given a
    filename, instead of calling the seek() and readinto() methods of a
    Python file object for every read. Opening and reading a large file with
    many objects is about four to five times faster, matching the speed of
    memory mapping (access_mode=AccessMode.mmap). Streams passed to
    {func}pikepdf.open, including plain file objects, are read through their
    methods as before.
  • Documented {class}pikepdf.TokenFilter with worked examples that shorten
    numbers and convert RGB colors to grayscale, and explained when to use a
    token filter instead of {func}pikepdf.parse_content_stream. The API
    reference no longer says that the parser should not be used to edit content
    streams. The TokenFilter.handle_token documentation now says correctly that
    exceptions it raises propagate to the caller. {issue}62

v10.16.0

Compare Source

  • Added binary wheels for Windows on ARM64. Thanks to @​ndabas. {issue}744
  • Binary wheels now bundle qpdf 12.4.2, which is also the new minimum version
    of qpdf, since it is the first release with Windows ARM64 binaries.
  • {func}pikepdf.sanitize.remove_javascript,
    {func}pikepdf.sanitize.remove_external_access,
    {func}pikepdf.sanitize.remove_multimedia and the matching
    {class}pikepdf.sanitize.Sanitizer steps missed actions attached to form
    field dictionaries. Actions survived on a field stored separately from its
    widget annotation, on a hidden field with no widget (such as a calculation
    helper), on nested fields under /Kids, and on widgets that appear on no
    page. The sanitizer now walks the whole /AcroForm field tree. Thanks to
    Stjorn for the report.
  • The same sanitizer steps left an action /Next chain untouched past its
    depth limit of 50, so a targeted action (for example a /JavaScript action)
    buried deeper survived, and the step that preserves benign downstream actions
    could promote it to a shallower position. The chain is now severed at the
    limit, which also drops any benign actions past it. Thanks to @​Nayana-Naik73.
    {issue}746
  • The sanitizer now also drops anything in a /Next chain that is not an
    action dictionary, such as a nested array, instead of passing it through
    unexamined. It raised AttributeError or ValueError on some such values
    (for example /Next [42]), and now runs in explicit conversion mode
    regardless of the caller's settings, so malformed values of the wrong type
    are skipped rather than crashing it.

v10.15.0

Compare Source

PDF/A-3 attachments
  • Attaching a file through Pdf.attachments now lists its file specification
    in the document catalog's /AF (associated files) array, and deleting or
    replacing an attachment removes its entry. Together with the
    /AFRelationship pikepdf already writes, a file attached to a PDF/A-3
    document now keeps it conformant. qpdf maintains only the /EmbeddedFiles
    name tree, so this was previously left to the user. {issue}463
  • The PDF/A validator now approves embedded files in PDF/A-3b documents: the
    /EmbeddedFiles name tree and the catalog's /AF array are checked against
    clause 6.8 of ISO 19005-3 (MIME type, /F and /UF, /AFRelationship,
    and that every embedded file is an associated file). Embedded files anywhere
    else, such as in file attachment annotations, are still reported as
    unsupported; they remain violations in PDF/A-1b and unsupported in PDF/A-2b.
    {func}pikepdf.pdfa.prepare gives PDF/A-3 embedded files a missing MIME type
    (application/octet-stream) and /AFRelationship (/Unspecified), and
    lists unassociated ones in the catalog's /AF array; new
    {class}pikepdf.pdfa.PrepareResult fields count these repairs. See
    {ref}pdfa-attachments.
PDF/A named destinations
  • The PDF/A validator now checks named destinations, in the /Dests name tree
    and in the catalog's /Dests dictionary, instead of reporting them as
    unsupported. Named destinations are common: pdfTeX (hyperref), Acrobat
    Distiller and JasperReports write them. It also checks named appearance
    streams (/Names /AP) as Form XObjects.
  • /AlternatePresentations is now reported as a violation of PDF/A-2 and
    PDF/A-3 (clause 6.10), and document-level JavaScript (/Names /JavaScript)
    as a violation of the rule forbidding JavaScript actions; both were
    reported as unsupported. {func}pikepdf.pdfa.prepare removes them.
  • {func}pikepdf.pdfa.prepare gives the encoding of a non-symbolic TrueType
    font that has /Differences but no /BaseEncoding the base encoding
    /WinAnsiEncoding, as PDF/A-2 and PDF/A-3 require, when no glyph the
    document draws would change. Older producers such as OpenPDF write such
    encodings. New {class}pikepdf.pdfa.PrepareResult fields report these
    repairs.
PDF/A developer extensions
  • The PDF/A validator now checks the Adobe developer extensions dictionary
    (/Extensions << /ADBE ... >>) that Acrobat writes in the document catalog,
    instead of reporting every such file as unsupported. qpdf rewrites this
    entry to match the written version and extension level, and removes it for
    PDF/A-1, and the validator checks the entry as it will be written. Other
    developer extensions remain unsupported.
  • {func}pikepdf.pdfa.resolve_save_kwargs accepts an extension level in
    min_version or force_version for PDF/A-2 and PDF/A-3, such as
    ('1.7', 8).
Metadata
  • New {meth}pikepdf.models.PdfMetadata.copy_properties copies named XMP
    properties from other metadata with their whole value: every language of a
    language alternative, array order, structures and qualifiers, which
    assigning a value read from the source would lose. Properties are read from
    every rdf:Description whatever its rdf:about, and the structure of known
    properties is checked as for assignment. This is useful to restore metadata
    another tool dropped while rewriting a document.
PDF/A annotations
  • {func}pikepdf.pdfa.repair_annotation_flags, the step of
    {func}pikepdf.pdfa.prepare that removes hidden annotations and sets the
    Print flag on the rest, is now public, with its result
    {class}pikepdf.pdfa.AnnotationRepairResult. Running it before handing a file
    to another PDF/A converter such as Ghostscript keeps hyperlinks that producers
    wrote without the Print flag, which Ghostscript's PDF/A mode deletes.
Fixes
  • The PDF/A validator reported the standard stream key /DL (decoded length)
    as unsupported on content streams, images, metadata streams and output
    intent profiles, so a file whose producer writes it could not be converted.
    It is now accepted on every stream.
  • The PDF/A validator accepted glyph names in a non-symbolic TrueType font's
    /Differences only from the Adobe Glyph List for New Fonts, so it rejected
    valid PDF/A-2 and PDF/A-3 files that used other names from the full Adobe
    Glyph List, such as afii10017 for Cyrillic text. It now accepts every name
    in the full list, as ISO 19005 requires and veraPDF checks. Names outside the
    list, such as uni0410 or A.sc, are still rejected.
  • A Pdf opened or created with conversion_mode='explicit' returned plain
    int for some numbers that qpdf writes itself, such as /Pages /Count
    after adding or removing a page, /Rotate after {meth}pikepdf.Page.rotate,
    or the /BBox of {meth}pikepdf.Page.as_form_xobject. These values now
    follow the document's conversion mode like any other.
  • In explicit conversion mode, Integer and Real now support the rest of
    the Python number protocol, with the same results as the int or Decimal
    that implicit mode produces: round(), math.trunc(), math.floor(),
    math.ceil(), divmod(), and format specs such as f'{x:.2f}'.
    int() of a Real now truncates, as int() of a Decimal does, instead
    of raising TypeError; for example int(page.Rotate) now works on a
    /Rotate 90.0.
  • The type stubs for Matrix now accept a pikepdf.Object, such as a
    /Matrix array, and a list of objects, as the runtime always has.

v10.14.0

Compare Source

Several improvements to explicit conversion mode and NamePath, prompted by
the OCRmyPDF project's migration to these APIs
(pikepdf.explicit_conversion(), the as_* safe accessors, and NamePath)
in a production codebase that reads untrusted, often malformed, PDFs.

Python support
  • Dropped support for Python 3.10, which reaches end of life on October 31,
    2026. Python 3.11 through 3.14 are supported, and wheels are no longer built
    for CPython 3.10. pip will keep installing pikepdf 10.13 on Python 3.10.
  • Internal code now uses Python 3.11 features: tomllib, enum.StrEnum,
    typing.Self, datetime.UTC and the broader ISO 8601 support in
    datetime.fromisoformat. The compatibility shims for Python 3.10 are gone.
  • CI now tests against CPython 3.15 (release candidate). CPython 3.15 uses the
    existing cp314-abi3 wheel; free-threaded CPython 3.15 gets its own
    cp315t wheel, since the stable ABI does not cover free-threaded builds.
Platform support
  • macOS wheels are now built on GitHub's macos-15 runner, since GitHub is
    deprecating the macos-14 runner. Binary wheels now require macOS 15 or newer.
  • Dropped macOS Intel (x86_64) wheels. We no longer test macOS on Intel, since
    the platform is end of life. Intel Mac users can build from source, or keep
    using pikepdf 10.13.
Conversion mode
  • {meth}pikepdf.Pdf.open and {meth}pikepdf.Pdf.new now accept a
    keyword-only conversion_mode argument ('implicit' or 'explicit'), and
    the mode can be read or changed afterward through the new
    {attr}pikepdf.Pdf.conversion_mode property. A Pdf's mode travels with
    it across threads and does not affect any other document, which makes it
    the right scope for a library embedded inside a host application. Setting
    the property to None reverts to inheriting the context-manager/global
    mode.
  • Added {func}pikepdf.implicit_conversion, a thread-local context manager
    symmetric with {func}pikepdf.explicit_conversion, so implicit mode can be
    forced from inside code that runs under explicit mode.
  • Precedence when several scopes are in play: context manager, then per-Pdf
    mode, then the global default set by
    {func}pikepdf.set_object_conversion_mode. An object with no owning Pdf
    (e.g. a bare pikepdf.Dictionary(...) you have not yet attached to a
    document) resolves through the context-manager/global scopes; once it is
    inserted into a Pdf it follows that document's mode.
  • Added {meth}pikepdf.Object.get_raw, which behaves like
    {meth}~pikepdf.Object.get (key, Name, or NamePath, plus a default)
    but never unboxes the result: it always returns a pikepdf.Object
    regardless of the current conversion mode. A null stored inside an array
    comes back as a Null-typed object rather than None; in a dictionary,
    qpdf treats a key whose value is null as absent, so get_raw returns the
    default for it, exactly as get does.
  • Added container-level typed getters {meth}~pikepdf.Object.get_int,
    {meth}~pikepdf.Object.get_bool, {meth}~pikepdf.Object.get_float,
    {meth}~pikepdf.Object.get_decimal, {meth}~pikepdf.Object.get_dict, and
    {meth}~pikepdf.Object.get_list, each (key_or_path, default=None). These
    compose get_raw with the matching as_* accessor, so reading an optional
    value of uncertain type is a mode-independent one-liner instead of a
    hand-written with pikepdf.explicit_conversion(): ... wrapper.
  • Added coerce=True to {meth}~pikepdf.Object.as_int,
    {meth}~pikepdf.Object.as_bool, {meth}~pikepdf.Object.as_float, and
    {meth}~pikepdf.Object.as_decimal, and to the corresponding get_*
    getters, for reading values that real-world PDFs encode with a "nearby"
    type: as_int(coerce=True) accepts a Real (truncated toward zero) and a
    numeric String; as_bool(coerce=True) accepts a nonzero Integer or
    Real (fixing the common /Marked 1 case that previously required a
    fallback to as_int() != 0); as_float/as_decimal with coerce=True
    accept an Integer and a numeric String, including exponent notation
    such as "1e-5".
  • pikepdf.Integer and pikepdf.Real now support the ordering comparisons
    <, <=, > and >= against Python int, float, bool, Decimal,
    and each other, so box[0] < box[2], sorted(), min() and max() work
    on explicit-mode values. Real compares by its exact decimal value.
  • Arithmetic on pikepdf.Integer and pikepdf.Real now works between two
    objects (Real('2.5') + Integer(3)) and with Decimal and bool
    operands, and ** is supported. Results are the native Python type that
    implicit mode would have produced: int for Integer with int/Integer,
    Decimal whenever a Real or Decimal is involved, and float with a
    float operand. In explicit mode, box[2] - box[0] > 100 therefore works
    without unboxing, while raising TypeError if the PDF stored a non-number.
    The result is never a pikepdf object: a number computed from a document is
    not in the document, and returning an object would let one unmigrated read
    propagate into code far from the cause.
  • Added {func}pikepdf.unbox, which returns the native Python value of an
    Integer, Boolean or Real and passes any other value through
    unchanged. Unlike the as_* accessors it does not require knowing which
    numeric type a value has, and it accepts values read in either mode, so it
    is the one-token migration for a read that feeds isinstance, is True,
    Decimal(), json.dumps or a function documented to return a native type.
  • Added module-level typed conversions {func}pikepdf.as_int,
    {func}~pikepdf.as_bool, {func}~pikepdf.as_float,
    {func}~pikepdf.as_decimal, {func}~pikepdf.as_dict,
    {func}~pikepdf.as_list, {func}~pikepdf.as_str and
    {func}~pikepdf.as_bytes, each (value, default=None), with keyword-only
    coerce for the numeric and boolean ones. They are the value-side twins of
    the get_* typed getters, for an array element, content stream operand or
    other value already in hand: a pikepdf object converts exactly as its
    as_* method does, and a native value is accepted only if it is the type
    implicit mode would have produced for that PDF type, so the result is the
    same in either conversion mode. pikepdf.as_int(True) gives the default,
    because a Boolean is not an Integer.
  • Added {meth}~pikepdf.Object.as_str and {meth}~pikepdf.Object.as_bytes,
    which return a String's decoded text or raw bytes, and raise TypeError
    (or return a supplied default) for any other type, unlike str() and
    bytes(), which accept almost anything. Added the matching typed getters
    {meth}~pikepdf.Object.get_str and {meth}~pikepdf.Object.get_bytes.
  • See {doc}/topics/objects for the full description of scopes and
    precedence, plus a "Migrating to explicit mode" checklist.
  • Added a new topic page, {doc}/topics/type_safety, explaining why
    explicit mode exists and setting out the deprecation schedule: v11 warns
    on implicit conversions, v12 makes explicit mode the default, and v13
    removes implicit mode. New code that reads values of uncertain type should
    prefer the mode-independent getters described above.
NamePath
  • path in obj now tests whether the path can be traversed to a value, and
    del obj[path] deletes the final component after traversing to its
    parent, both for name and array-index components.
  • NamePath is now iterable, yielding its individual components (str for
    names, int for indices) in order, e.g. list(NamePath.A.B[0]) gives
    ['/A', '/B', 0].
  • NamePath instances now compare and hash by their component sequence, so
    NamePath.A.B == NamePath.A.B is True and a NamePath can be used as a
    dict key or stored in a set.
  • isinstance(path, pikepdf.NamePath) now works, and pikepdf.NamePath can
    be used directly in type annotations (e.g.
    def f(key: pikepdf.Name | pikepdf.NamePath)) without importing a private
    name.
Metadata and PDF/A

OCRmyPDF tested its PDF/A output against veraPDF, and found files that
pikepdf's metadata handling made invalid.

  • XMP language alternatives such as dc:title and dc:description are now
    read from their x-default item, as the XMP specification defines, rather
    than from the first item. Acrobat writes x-default last when a document
    has several languages, so /Title and /Subject were synced from the wrong
    language, and PDF/A-1 validators rejected the result.
  • Behavior change: Setting a language alternative now updates its
    x-default item and keeps the other languages, instead of replacing all of
    them with the new value. An item that held the same text as the old default
    is updated too, as Adobe's XMP toolkit does. Assigning several values to a
    language alternative that pikepdf does not know joins them into one
    x-default item, instead of writing several x-default items.
  • XMP properties are now read from every top-level rdf:Description, not only
    those with rdf:about="". Properties in Descriptions with
    rdf:about="uuid:..." (written by Distiller and older Acrobat) or with no
    rdf:about could not be read or deleted, and setting one added a duplicate,
    which made veraPDF reject the whole packet. Setting a property now removes
    any other occurrences of it, and deleting it removes all of them.
  • Behavior change: When XMP is written, every top-level rdf:Description
    gets the same rdf:about value, as the XMP specification requires, and
    empty Descriptions are removed. The value is kept if the non-empty values
    agree, and made empty if they conflict.
  • Added {attr}pikepdf.models.PdfMetadata.recovered and
    XmpDocument.recovered, which are True if the XMP was not well-formed and
    had to be repaired or replaced as it was read.
  • Added {meth}pikepdf.PdfInlineImage.read_raw_bytes, which returns the
    still-encoded data of an inline image exactly as it appears in the content
    stream.
  • {meth}pikepdf.Pdf.save now corrects /Count in each node of the page
    tree to the number of pages beneath it. qpdf repairs a damaged page tree but
    left /Count as it was, so a wrong /Count in the input was written
    unchanged, and veraPDF could not validate the file at all.
PDF/A validation and repair
  • Added the {mod}pikepdf.pdfa module, which prepares, checks and saves
    PDF/A-1b, PDF/A-2b and PDF/A-3b documents. See {ref}pdfa.
    • {func}pikepdf.pdfa.prepare repairs a document in memory: it installs a
      PDF/A output intent (sRGB by default, or a supplied ICC profile), removes
      image interpolation and hidden annotations, adds /CIDSet for PDF/A-1,
      and rewrites the XMP metadata with a PDF/A declaration. It returns a
      {class}~pikepdf.pdfa.PrepareResult describing what changed:
      {meth}~pikepdf.pdfa.PrepareResult.describe gives a sentence per change,
      {meth}~pikepdf.pdfa.PrepareResult.messages the same sentences with a
      suggested log level, and PrepareResult.xmp_problem why an XMP packet
      could not be read. XMP properties are kept from every rdf:Description
      when all share one rdf:about, including the non-empty uuid:... value
      that Acrobat and pikepdf's own metadata editor write.
    • {func}pikepdf.pdfa.check predicts the verdict for the file that would be
      written, without writing it, by modelling what qpdf's writer changes
      (stream filters, trailer, version, encryption and which objects are
      written).
    • {func}pikepdf.pdfa.save prepares the document, writes it to a temporary
      file, reopens and validates the bytes written, and only then moves the file
      into place. If the written file does not pass, it raises
      {class}~pikepdf.pdfa.PdfaError with the report (whose prepared records
      the repairs made), and the destination is left untouched.
    • {func}pikepdf.pdfa.resolve_save_kwargs returns the complete
      {meth}pikepdf.Pdf.save settings for a flavour. Settings that PDF/A
      forbids or that would change the bytes after the check (such as
      encryption, normalize_content and fix_metadata_version) are pinned,
      and a conflicting value raises ValueError.
  • The validator is an allowlist: it approves only constructs it recognizes and
    knows to conform. A {class}~pikepdf.pdfa.Report has a verdict of 'pass',
    'fail' (at least one violation) or 'not_checked' (only constructs the
    validator does not check, which may be valid PDF/A). save accepts only
    'pass'. Each {class}~pikepdf.pdfa.Finding names a rule: a veraPDF rule id
    such as ISO_19005_2:6.2.8-3, or a pikepdf: id for local policies and
    unsupported constructs. The validator is not a certification; veraPDF
    remains the reference.
  • On the 2,906 files of the veraPDF test corpus, converted with prepare and
    checked against veraPDF 1.30 for each of PDF/A-1b, 2b and 3b, the validator
    approved no file that veraPDF rejects. For PDF/A-2b it approved 1,363 files,
    rejected 887 and left 656 not checked; veraPDF accepted 28 of the rejected
    files (the validator is conservative by design). The prediction from check
    matched the validation of the written file in every case.
  • The validator and the repairs give the same results whether a document is
    read in implicit or explicit conversion mode: they work in explicit mode
    internally, whatever mode the caller uses.
  • {mod}pikepdf.pdfa needs jsonschema, referencing and fontTools, available as
    the optional extra pip install 'pikepdf[pdfa]'. import pikepdf does not
    import them; import pikepdf.pdfa raises ImportError naming the extra if
    they are missing.
  • The PDF/A rule catalogue is derived from the veraPDF validation
    profiles (CC BY 4.0, veraPDF Consortium); see
    third-party-licenses/README.md.
  • Added the internal helper pikepdf._io.atomic_write_verified, which writes a
    file to a temporary location, calls a verification function on it, and moves
    it into place only if verification succeeds. pikepdf.pdfa.save uses it.
qpdf limits
  • Added {func}pikepdf.settings.get_qpdf_limits and
    {func}pikepdf.settings.set_qpdf_limits, which read and change qpdf's
    process-wide limits for hardening against malicious or damaged PDFs: parser
    nesting depth, error count and container size, the number of stream filters,
    memory for decoding Flate, DCT, PNG, TIFF and RunLength data, and whether
    corrupt JPEG data is an error. Previously only some of these limits were
    reachable, through {meth}pikepdf.JobBuilder.limits. set_qpdf_limits
    returns the previous values so they can be restored.
  • Added {func}pikepdf.settings.disable_qpdf_default_limits, which lifts
    qpdf's optional default limits for the rest of the process, and
    {func}pikepdf.settings.qpdf_limit_errors, which counts how many times any
    limit has been exceeded.
Behavior changes
  • The minimum required qpdf version is now 12.4.1, and wheels bundle qpdf
    12.4.1. Changes inherited from qpdf 12.4:
    • Content stream parsing ({func}pikepdf.parse_content_stream,
      {meth}pikepdf.Page.parse_contents) now stops after 15 syntax errors,
      issuing a warning. Instructions after that point are dropped, so parsing
      and rewriting a badly damaged content stream can lose content. Use
      pikepdf.settings.set_qpdf_limits(parser_max_errors=0) to parse as much
      as possible.
    • A page tree nested more than 100 levels deep now raises
      {class}pikepdf.PdfError when the pages are accessed.
    • /Rotate values outside [0, 360), such as -90, are now normalized
      when a page is converted to a form XObject, overlaid or rotation-flattened.
    • JSON output of real numbers no longer includes leading zeroes.
  • The progname keyword argument of {class}pikepdf.Job is deprecated and
    ignored, and passing it issues a DeprecationWarning. It was passed to
    qpdf's QPDFJob::initializeFromArgv as the name of an environment variable,
    not the program name, and qpdf 12.4 no longer uses it. The program name is
    taken from the first item of args, as it always was.
  • Behavior change: Reading PdfImage metadata such as .width,
    .height or .colorspace whose value has the wrong PDF type (for example
    a /Width written as a string or name) now raises TypeError, with a
    message naming the key and the value found, instead of
    NotImplementedError: Metadata access for Width. The exception is also a
    NotImplementedError, so existing handlers keep working.
  • Behavior change: A pikepdf.String no longer compares equal to
    bytes: pikepdf.String('abc') == b'abc' is now False. It still
    compares equal to the str it decodes to. A String compared equal to
    both a str and a bytes that are unequal to each other, and so could not
    hash like both of them; for non-ASCII text it hashed like neither, so
    {pikepdf.String('héllo'): 1}['héllo'] raised KeyError. A String now
    hashes like its str. To compare the raw data, use bytes(s) == b'...' or
    {meth}~pikepdf.Object.as_bytes.
  • Behavior change: A pikepdf.Name no longer compares equal to bytes:
    pikepdf.Name('/Foo') == b'/Foo' is now False. It still compares equal to
    the str of its UTF-8 bytes, so obj.Type == '/Page' works as before, and
    it now hashes like that str, so {pikepdf.Name('/héllo'): 1}['/héllo']
    no longer raises KeyError. As PDF 2.0 (ISO 32000-2, 7.3.5) requires,
    names are compared byte for byte, with no Unicode normalization. Use
    bytes(name) == b'...' to compare the raw bytes.
  • Behavior change: A pikepdf.Real combined with an int, Integer, or
    Decimal, or negated with unary -/+/abs(), now yields a Decimal
    (previously a float, or TypeError for int operands other than /).
    A Real with a float operand still yields a float. Division of an
    Integer or Real by zero now raises ZeroDivisionError, as for Python
    numbers, instead of ValueError.
  • Behavior change: {class}pikepdf.Matrix now raises TypeError, not
    ValueError, for a pikepdf.Object that is not a matrix or an
    ObjectList with a non-numeric element, matching what a native argument of
    the wrong type raises, so an except TypeError around Matrix(*operands)
    behaves the same in either conversion mode. Size errors (must have 6 elements) remain ValueError.
  • Behavior change: bool() on a pikepdf.Integer or pikepdf.Real is
    now by value (bool(pikepdf.Integer(0)) is False), instead of raising
    NotImplementedError: code is unreachable.
  • Behavior change: {meth}~pikepdf.Object.as_dict and
    {meth}~pikepdf.Object.as_list now accept a default argument and raise
    TypeError on a type mismatch, instead of raising pikepdf.PdfError with
    no way to supply a default.
  • Behavior change: Objects created in Python are now adopted by the Pdf
    they are inserted into, so pdf.Root.X = 42 followed by
    pdf.Root.get_raw('/X').is_owned_by(pdf) is True, matching objects parsed
    from a file. Scalars (Name, String, Integer, ...) are adopted as a copy,
    so a handle held in a constant can still be inserted into several documents.
    A Dictionary or Array is adopted in place and keeps its aliasing with the
    document; inserting the same container into a second Pdf now raises
    ForeignObjectError, as it already did for containers parsed from a file.
    Construct a new object, or use {meth}pikepdf.Pdf.copy_foreign. Adoption is
    not permanent: removing the object from the document -- deleting or
    replacing the dictionary key or array element that held it, or destroying
    the document -- releases the claim, so the object can then be inserted into
    another Pdf. If the same object was reachable under two keys, removing
    either one releases it; its value is unaffected and still readable through
    the remaining reference.
  • Behavior change: Objects copied into a document are adopted by it too.
    The direct children of an object produced by
    {meth}pikepdf.Pdf.copy_foreign, {meth}pikepdf.Object.with_same_owner_as,
    {meth}pikepdf.Pdf.make_indirect, or by appending/inserting a page into
    Pdf.pages, and values inserted through NameTree/NumberTree
    __setitem__, now report the destination document as their owner and follow
    its conversion_mode.
  • Behavior change: {meth}pikepdf.Object.with_same_owner_as and
    {meth}pikepdf.Pdf.make_indirect now raise ForeignObjectError for a
    direct object that already belongs to a different Pdf, instead of silently
    retagging an object that the other document still references. Remove it from
    that document first, or make it indirect there and use
    {meth}pikepdf.Pdf.copy_foreign.
  • Behavior change: {meth}~pikepdf.Object.as_int with coerce=True now
    returns a supplied default for a value that does not fit in a 64-bit PDF
    integer, instead of raising OverflowError. Called without a default it
    still raises OverflowError.
  • Behavior change: repr() of a pikepdf.Object now honors the
    effective conversion mode of the object being displayed (context manager,
    then its owning Pdf, then the global setting), rather than only the
    global setting.
  • Behavior change: {func}pikepdf.set_object_conversion_mode now raises
    ValueError for a value other than 'implicit' or 'explicit', instead
    of silently accepting it.
Performance
  • {meth}pikepdf.Pdf.save writes directly to the file descriptor when saving
    to a filename or to a plain binary file object from {func}open, instead of
    calling the stream's write() method for every chunk of output. Saving a large document is about twice as fast. Other streams, such
    as BytesIO, pipes and subclasses of the io classes, are written through
    write() as before.
  • isinstance() checks against {class}pikepdf.Dictionary,
    {class}pikepdf.Stream, {class}pikepdf.Integer and the other object
    classes are about five times faster.
  • {func}pikepdf.unbox is now implemented in C++ and is about 40 times
    faster. {func}pikepdf.as_int, {func}pikepdf.as_float and
    {func}pikepdf.as_decimal answer for a native int or Decimal without
    constructing a PDF object, and converting a Real to a Decimal no longer
    imports the decimal module each time.
Fixes
  • {func}pikepdf.models.metadata.decode_pdf_date now accepts every PDF date
    form the specification allows, in which all f

[!IMPORTANT]
✂ PR body was truncated to here.


Configuration

📅 Schedule: (UTC)

  • Branch creation
    • At any time (no schedule defined)
  • Automerge
    • At any time (no schedule defined)

🚦 Automerge: Enabled.

♻ Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about this update again.


  • If you want to rebase/retry this PR, check this box

This PR was generated by Mend Renovate. View the repository job log.

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.72%. Comparing base (27dd2ac) to head (7da7f90).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #571   +/-   ##
=======================================
  Coverage   72.72%   72.72%           
=======================================
  Files           4        4           
  Lines          44       44           
=======================================
  Hits           32       32           
  Misses         12       12           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renovate
renovate Bot force-pushed the renovate/pikepdf-10.x branch 6 times, most recently from 84f2be2 to c5ebc41 Compare November 13, 2026 13:56
@renovate
renovate Bot force-pushed the renovate/pikepdf-10.x branch 7 times, most recently from a31b517 to e31f756 Compare November 20, 2026 08:30
@renovate
renovate Bot force-pushed the renovate/pikepdf-10.x branch 4 times, most recently from 981701c to ac34ad3 Compare November 27, 2026 03:11
@renovate
renovate Bot force-pushed the renovate/pikepdf-10.x branch 2 times, most recently from a2a05ff to edc0fbd Compare December 1, 2026 13:35
@renovate
renovate Bot force-pushed the renovate/pikepdf-10.x branch from edc0fbd to 7da7f90 Compare December 1, 2026 22:15

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants