unstale

pypi / fpdf2

fpdf2

What changed in fpdf2 2, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

24 breaking1 security29 new APIs and options1 performance14 behavior and defaults88 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

fpdf2 2157 changes

Breaking changes 24

  • Repeated flags no longer change unrelated bits; flags are combined with bitwise OR.

    2.9.0release notes

  • The dependency was removed; SVG parsing uses standard-library ElementTree and Expat amplification limits, and bounded internal entities are accepted.

    2.9.0release notes

  • Construction and add_page reject page formats with zero or negative width or height.

    2.9.0release notes

  • Accepts empty byte content and rejects simultaneous path and byte sources even when bytes are empty.

    2.9.0release notes

  • An empty coords sequence now raises a clear ValueError.

    2.9.0release notes

  • numSides below 1 raises a clear ValueError instead of silently writing a path with no points.

    2.9.0release notes

  • Negative margins raise ValueError instead of placing page breaks below the page edge.

    2.9.0release notes

  • Negative or non-numeric zoom values raise FPDFException instead of writing an invalid zoom or failing later.

    2.9.0release notes

  • Negative line widths raise ValueError instead of writing a width disallowed by the PDF specification.

    2.9.0release notes

  • label_start below 1 raises ValueError instead of writing an invalid PDF start value.

    2.9.0release notes

  • Zero or negative stretching raises ValueError instead of breaking text layout.

    2.9.0release notes

  • corners below 1 raise a clear ValueError instead of a ZeroDivisionError or drawing nothing.

    2.9.0release notes

  • Content inside style and script elements is no longer written into the document as text.

    2.9.0release notes

  • Nested tables in table cells raise a descriptive NotImplementedError instead of a bare AssertionError.

    2.9.0release notes

  • Hex strings containing non-hexadecimal characters now raise a clear ValueError.

    2.9.0release notes

  • An index not returned by FPDF.add_link now raises a clear ValueError instead of an assertion or KeyError.

    2.9.0release notes

  • Out-of-range color components are reported as given rather than normalized.

    2.9.0release notes

  • A zero width or height disables rendering instead of using viewport dimensions.

    2.9.0release notes

  • Booleans in arrays and dictionaries serialize as lowercase true and false, None in arrays as null, and filtering empty dictionary fields preserves False and numeric zero.

    2.8.9release notes

  • A custom height passed in a text region is now applied to the line it terminates, rather than the first line of the following paragraph.

    2.8.8release notes

  • Rejects SVG <use> cycles and excessive nested expansion to prevent resource exhaustion in FPDF.image().

    2.8.8release notessecurity advisory

  • The deprecated uni parameter was removed.

    2.8.5release notes

  • The deprecated dest parameter was removed.

    2.8.5release notes

  • Changed accept_page_break into a property.

    2.0.0release notes

Security 1

  • fpdf2 implicitly loads external URLs and local image paths when rendering attacker-controlled content

    2.8.8security advisory

New APIs and options 29

  • Create colored and uncolored tiling patterns, including SVG pattern elements and pattern fills and strokes on referenced use shapes.

    2.9.0release notes

  • Supports type="none" to render list items without markers.

    2.9.0release notes

  • SVG <image> tags now support transform, style, opacity, and preserveAspectRatio="none".

    2.9.0release notes

  • Adds an align parameter to control horizontal alignment of page-number substitution text inside reserved alias space.

    2.8.9release notes

  • Adds an appearance parameter accepting FileAttachmentAppearance.HIDDEN to hide the annotation's default icon while keeping the embedded file reachable.

    2.8.9release notes

  • Adds support for page number alias substitution with bidirectional and RTL text shaping.

    2.8.9release notes

  • Adds configurable SVG complexity limits when rendering SVG images.

    2.8.8release notes

  • Adds support for keeping aspect ratio for images in templates.

    2.8.8release notes

  • Adds basic support for SVG <switch> elements in the SVG parser.

    2.8.8release notes

  • Adds basic support for SVG <symbol> elements in the SVG parser.

    2.8.8release notes

  • Adds TTC/OTC face selection through the collection_font_number parameter.

    2.8.6release notes

  • Adds support for embedding CID-keyed CFF fonts.

    2.8.6release notes

  • Adds support for EBDT/EBLC bitmap fonts.

    2.8.6release notes

  • Adds a context manager for applying geometric transformations to the current graphics state.

    2.8.6release notes

  • Graphics state snapshots now use a dataclass, providing clearer usage and stronger typing.

    2.8.6release notes

  • SVG rendering now supports linear and radial gradient elements.

    2.8.6release notes

  • Adds support for WOFF and WOFF2 fonts.

    2.8.6release notes

  • The new parameter selects alternate color palettes from COLR/CPAL color fonts, enabling different color schemes without embedding the font multiple times.

    2.8.5release notes

  • The new parameter restricts which Unicode characters a font covers.

    2.8.5release notes

  • The new parameter allows variable fonts to be used.

    2.8.5release notes

  • Bounding box support was added to the drawing API.

    2.8.5release notes

  • Color font glyphs can now be rendered in SBIX, CBDT/CBLC, SVG, COLRv0, and COLRv1 formats.

    2.8.5release notes

  • FlexTemplate elements now support dashed lines.

    2.8.5release notes

  • Gradient spread methods PAD, reflect, and repeat are supported.

    2.8.5release notes

  • The drawing API now supports gradients as fill or stroke colors.

    2.8.5release notes

  • Links can now target named destinations.

    2.8.5release notes

  • Native PDF/A compliance verification supports PDF/A-1B, 2B, 2U, 3B, 3U, 4, 4E, and 4F; accessible PDF/A documents are not yet supported.

    2.8.5release notes

  • The drawing API now supports Porter–Duff compositing operations.

    2.8.5release notes

  • Sweep (mesh) gradients are now supported.

    2.8.5release notes

Performance 1

  • Improves performance when rendering paths, SVGs, and opaque raster images with an alpha channel.

    2.8.6release notes

Behavior and default changes 14

  • Accepts CSS rgb(R, G, B) colors and surrounding spaces in color and bgcolor attributes.

    2.9.0release notes

  • Table, cell, hr and img dimensions accept CSS px and pt units and surrounding whitespace.

    2.9.0release notes

  • Ordered lists support <li value="N"> and continue subsequent numbering from that value.

    2.9.0release notes

  • Supports square bullets; Unicode fonts use ▪ and core fonts fall back to the bullet.

    2.9.0release notes

  • Encoding errors now identify the Unicode script and suggest a suitable font available on the system.

    2.9.0release notes

  • Markdown multi-cell text now supports unordered lists using *, - or + as bullet markers.

    2.9.0release notes

  • Homogeneous arrays use PDF serialization for strings and names, including encryption when applicable.

    2.9.0release notes

  • Python 3.15 is now officially supported.

    2.9.0release notes

  • Coordinates and corner radii now accept absolute length units.

    2.9.0release notes

  • opacity, fill-opacity and stroke-opacity accept percentages; out-of-range opacity is clamped to 0–1.

    2.9.0release notes

  • Fonts with both outline and bitmap glyphs now prefer outline glyphs.

    2.8.7release notes

  • Python 3.14 is now officially supported.

    2.8.5release notes

  • Basic support was added for the SVG currentColor value.

    2.8.5release notes

  • Support was added for more recent Python versions.

    2.0.0release notes

Fixes and other changes 88

  • Images are scaled down to 8 bits rather than converted to RGBA, and retain tRNS color-key transparency.

    2.9.0release notes

  • Values are serialized as PDF numbers without exponent notation.

    2.9.0release notes

  • Outlines count all visible descendants and link siblings by parent, retaining bookmarks when hierarchy starts below the top level.

    2.9.0release notes

  • Checksums for compressed embedded files are calculated from the original file bytes as required by the PDF specification.

    2.9.0release notes

  • font_style and emphasis setters are synchronized with font selection and state tracking.

    2.9.0release notes

  • The annotation rectangle's horizontal position is computed from path x coordinates so it encloses the drawn path.

    2.9.0release notes

  • Infinite numeric zoom values are rejected instead of producing invalid PDF numbers.

    2.9.0release notes

  • Repeated style letters are treated as the same style; style="BB" is bold.

    2.9.0release notes

  • An unknown borders_layout name raises ValueError instead of a bare AttributeError.

    2.9.0release notes

  • A cell with colspan below 1 spans one column instead of raising errors or breaking the column layout.

    2.9.0release notes

  • A text_align tuple with too few values now raises a clear ValueError naming the column instead of IndexError.

    2.9.0release notes

  • ncols below 1 raises a clear ValueError instead of a ZeroDivisionError or unrelated rendering error.

    2.9.0release notes

  • Tables replay with their rows and cells intact when an unbreakable block moves to a new page.

    2.9.0release notes

  • Unsupported align values on td, th and tr are ignored instead of raising ValueError.

    2.9.0release notes

  • Accepts legacy HTML colors written as six hex digits without a leading #.

    2.9.0release notes

  • Cells without explicit widths share remaining table space; colspan widths are divided equally among spanned columns.

    2.9.0release notes

  • Ignores transparent color and bgcolor values, preserving inherited text or background colors.

    2.9.0release notes

  • Invalid CSS color on a heading is ignored, preserving its color attribute or default color.

    2.9.0release notes

  • Invalid or sub-one colspan and rowspan values on table cells are treated as 1.

    2.9.0release notes

  • Uses the first available font in a <font face> list; generic serif, sans-serif and monospace families use core fonts.

    2.9.0release notes

  • Reads CSS font-size units on <font>; unitless numbers remain points.

    2.9.0release notes

  • An anchor without href, such as a named anchor, renders its text as plain text instead of raising KeyError.

    2.9.0release notes

  • Alphabetic ordered lists longer than 26 items continue with aa, ab, and start values below 1 display as numbers.

    2.9.0release notes

  • An unknown ordered-list type numbers items as 1, 2, 3 instead of raising NotImplementedError.

    2.9.0release notes

  • A rowspan extending past the final table row is stopped at that row.

    2.9.0release notes

  • Accepts ul type keywords in any case.

    2.9.0release notes

  • Empty or unknown ul type values keep the default bullet instead of raising NotImplementedError.

    2.9.0release notes

  • Oversized table widths render at page width with a warning; negative widths are ignored.

    2.9.0release notes

  • No longer warns about missing end tags for HTML void elements.

    2.9.0release notes

  • Aliases honor center and right alignment with core fonts when text shaping is enabled.

    2.9.0release notes

  • Years below 1000 are padded to four digits.

    2.9.0release notes

  • None values are serialized as PDF null instead of an invalid Python literal.

    2.9.0release notes

  • Numbers in arrays, dictionaries and destinations are written without exponent notation, preserving values and very small zoom factors.

    2.9.0release notes

  • CSS rgb() colors accept percentages in SVG import and FPDF.write_html, clamped to 0%–100%.

    2.9.0release notes

  • Byte strings and BytesIO inputs accept a UTF-8 BOM and XML whitespace after <svg> or <?xml> instead of going to the raster loader.

    2.9.0release notes

  • Color keywords are case-insensitive; fill and stroke accept transparent, which paints nothing like none.

    2.9.0release notes

  • Accepts percentages, clamps out-of-range values to 0–1, and combines with the color alpha channel.

    2.9.0release notes

  • Inline style declarations for stop-opacity take precedence over the corresponding presentation attribute.

    2.9.0release notes

  • Attributes accept scientific notation, such as width="1e2pt".

    2.9.0release notes

  • Malformed points draw up to the last complete point; empty points draw nothing.

    2.9.0release notes

  • Transform numbers may use scientific notation.

    2.9.0release notes

  • Bulleted paragraphs honor top margins, indented paragraphs retain the right boundary, and HTML list items honor TextStyle.t_margin.

    2.9.0release notes

  • PDF/A-1 documents using TrueType or CFF-based CID fonts now include a /CIDSet stream in each font descriptor, as required by ISO 19005-1.

    2.8.9release notes

  • Escaped Markdown markers adjacent to emphasis markers in link labels no longer lose literal characters or apply unintended styling.

    2.8.9release notes

  • List bullets now use correct font styling instead of inheriting styles from a preceding heading.

    2.8.9release notes

  • List line-height values that are not bare numbers are ignored, using the default line height instead of raising IndexError.

    2.8.9release notes

  • Now accepts 1-element sequences per CSS shorthand rules and preserves existing Padding instances without redundant allocations.

    2.8.9release notes

  • Fixes table cells landing in the wrong column when a row is covered by several rowspans that do not start in column order.

    2.8.9release notes

  • Percentage width and height values with surrounding whitespace no longer raise ValueError.

    2.8.9release notes

  • Fixes a visual gap in subsequent text rendering after a page alias when text shaping is enabled.

    2.8.9release notes

  • CMap mappings are split into blocks of at most 100 entries to meet the PDF specification.

    2.8.9release notes

  • Preserves boundary-neutral formatting during bidirectional text preprocessing.

    2.8.8release notes

  • Embeds CID-keyed CFF fonts as raw CFF programs so browser PDF viewers render them correctly.

    2.8.8release notes

  • Fixes the number of surviving escape characters.

    2.8.8release notes

  • Fixes text rendering when the first text on a page starts with a fallback glyph.

    2.8.8release notes

  • Dry runs now preserve link annotations and markdown formatting; ToC dry runs also preserve page order.

    2.8.8release notes

  • Can restore current_font when the selected font state has diverged.

    2.8.8release notes

  • Preserves consecutive markdown links without intervening spaces and supports markdown styling around links.

    2.8.8release notes

  • Treats RuntimeError like ImportError for the optional numpy import, so unsupported CPUs make numpy unavailable instead of causing import fpdf to fail.

    2.8.8release notes

  • Declares the default base state and display order so PDF viewers can list layers correctly.

    2.8.8release notes

  • Leading spaces on new lines inside preformatted blocks are no longer dropped.

    2.8.8release notes

  • Fixes rendering SVG arcs with very small sweeps that previously rounded to zero.

    2.8.8release notes

  • Counts SVG <switch> elements toward SVG complexity limits.

    2.8.8release notes

  • Font state no longer leaks onto the FPDF instance after text_columns() or text_region() exits, so subsequent cell() or write() calls use the caller's font.

    2.8.8release notes

  • Font state no longer leaks onto the FPDF instance after text_region() exits, so subsequent cell() or write() calls use the caller's font.

    2.8.8release notes

  • Avoids a spurious horizontal-space error when unbreakable text is split into many small fragments, such as by alternating fallback and main fonts.

    2.8.8release notes

  • Resets graphics state for ToC rendering and fixes page order after multi_cell dry runs in a ToC.

    2.8.8release notes

  • Fixes transform application on user space gradients.

    2.8.8release notes

  • Fixed the types for FPDF.add_font().

    2.8.7release notes

  • Fixed the types for FPDF.output().

    2.8.7release notes

  • Fixed the type for FPDF.title.

    2.8.7release notes

  • Reverted changes to ImageInfo that impacted the user-facing API.

    2.8.7release notes

  • Fixes an extra border rendered for empty tables using INTERNAL layout.

    2.8.6release notes

  • Fixes edge cases where tiny floating-point drift could trigger incorrect behavior.

    2.8.6release notes

  • Corrects the A5 page dimensions used when format is specified in the FPDF constructor.

    2.8.6release notes

  • ImageInfo now uses typed dictionaries for clearer usage and stronger typing.

    2.8.6release notes

  • Fixes parsing markdown sequences containing an escape character.

    2.8.6release notes

  • Adds remapping for Microsoft Symbol fonts with non-Unicode cmaps.

    2.8.6release notes

  • Escapes parentheses in more places, fixing embedding files whose filenames contain a single parenthesis; section names may also be affected.

    2.8.6release notes

  • Fixed a bug when merging fragments of different types.

    2.8.5release notes

  • GoTo actions for named destinations were fixed.

    2.8.5release notes

  • Destination page numbers are now updated when the ToC renderer spans multiple pages.

    2.8.5release notes

  • Detection logic changed to maintain compatibility with Pillow v12.

    2.8.5release notes

  • Fixed an issue with Markdown when fallback fonts contain non-alphanumeric characters.

    2.8.5release notes

  • Fixed rendering that caused visual distortions and incorrect filling.

    2.8.5release notes

  • Fixed missing cell clearance in spacing calculations.

    2.8.5release notes

  • The fvar font table is preserved to maintain compatibility with variable fonts.

    2.8.5release notes

  • Fixed a syntax error caused by an invalid /Transparency dict when the PDF version is greater than 1.3.

    2.0.0release notes