substitutefor

software · Q1133

fpdf2

Python PDF-generation library with page-layout, text, graphics and limited HTML input tools.

Suggest a correction

Overview

fpdf2 is a Python library for generating PDF documents and the successor to PyFPDF. It exposes operations for pages, text, tables, graphics and other PDF features, with automatic page breaks and a basic HTML input path. Its role is programmatic generation; workflows that incorporate an existing PDF may combine it with a separate manipulation library.[1][5]

Page and content generation

The library provides text cells, multi-line text, tables and automatic page breaks alongside image and path-drawing operations. Page dimensions, units, margins and optional headers or footers can be controlled in code. It also exposes document features such as links and outlines. These facilities allow an application to turn its own data into a document; they do not define the business logic or provide a graphical authoring interface.[1]

HTML input is a subset

The write_html interface handles selected HTML constructs through Python's HTML parser. The manual explicitly states that full HTML5 and CSS are not implemented, while documenting narrower styling controls and selected page-break properties. It also lists limitations for nested tags in table cells. A template written for a browser or a full HTML-to-PDF renderer should therefore be checked against this supported subset rather than assumed to transfer unchanged.[3]

Unicode and shaping

Unicode font handling and shaping are related but separate requirements. The shaping documentation makes uharfbuzz optional and leaves shaping disabled by default; enabling it supports the library's bidirectional-text handling. Type 1 fonts are excluded from this shaping path. For Arabic, Indic scripts or mixed-direction text, the font and shaping configuration are part of the workflow rather than a consequence of merely passing a Unicode string.[4]

Working with existing documents

The project's integration examples combine generated fpdf2 content with pypdf. One pattern produces a new overlay and merges it onto an existing page; another inserts a generated page into an existing document. These examples show complementary responsibilities: fpdf2 creates the new material, and pypdf reads and manipulates the existing PDF. They do not establish that fpdf2 itself imports arbitrary PDFs as an editable native document.[5]

Licensing and substitution

The package metadata specifies LGPL-3.0-only and Python 3.10 or later, with Pillow, fontTools and defusedxml dependencies. fpdf2 can substitute for ReportLab Toolkit for suitable Python-generated documents, but their layout APIs differ. Choose around the required tables, typography and page behavior, and preserve output checks when translating code. The PyFPDF lineage does not make this a drop-in implementation of another toolkit's document templates.[1][2][6]

Capabilities & limitations

Programmatic PDF generation

supported

Provides text, tables, images, drawing and automatic page breaks.[1]

Generating PDF documents from Python · Python 3.10+; OS-independent base · Version, build and integration requirements apply

1 source · check evidence
https://py-pdf.github.io/fpdf2/

Generation features and PyFPDF succession

vendor · checked 2026-10-07

HTML/CSS compatibility

limited

Supports a basic HTML subset rather than full HTML5/CSS; selected inline page-break controls are documented.[3]

Generating PDF documents from Python · Python 3.10+; OS-independent base · Version, build and integration requirements apply

1 source · check evidence
https://py-pdf.github.io/fpdf2/HTML.html

Basic HTML subset, styling exceptions and nesting limits

vendor · checked 2026-10-07

Complex text shaping

limited

Disabled by default, requires uharfbuzz and excludes Type 1 fonts.[4]

Generating PDF documents from Python · Python 3.10+; OS-independent base · Version, build and integration requirements apply

1 source · check evidence
https://py-pdf.github.io/fpdf2/TextShaping.html

Opt-in uharfbuzz, font limitations and bidirectional text

vendor · checked 2026-10-07

Can substitute for

These are products or services this entry can replace. Check the task and limitations for each comparison.

ReportLab Toolkit for Generating PDF documents from Python

limited

Can cover Python-driven PDF generation; page-layout APIs and template models require adaptation.[1][6]

Python 3.10+; OS-independent base · Version, build and integration requirements apply

References

  1. fpdf2 documentation

    Generation features and PyFPDF succession

    vendor · retrieved 2026-10-07
  2. fpdf2 package metadata

    LGPL-3.0-only, Python 3.10+ and dependencies

    vendor · retrieved 2026-10-07
  3. fpdf2 HTML input

    Basic HTML subset, styling exceptions and nesting limits

    vendor · retrieved 2026-10-07
  4. fpdf2 text shaping

    Opt-in uharfbuzz, font limitations and bidirectional text

    vendor · retrieved 2026-10-07
  5. Combining fpdf2 with pypdf

    Generated overlays, new pages and existing document manipulation

    vendor · retrieved 2026-10-07
  6. ReportLab Platypus

    Flow-based Python PDF generation

    vendor · retrieved 2026-10-07

Discussion & disputes

Ask about unclear claims or explain a concern with supporting sources. If you have a specific fix, suggest a correction.

No discussion yet.

Sign in with an active account to join the discussion.

Revision history

Open a revision to read an earlier version of this article.

RevisionTimestampEdit summary
11812026-10-13 22:49:59/* wbeditentity-create-item:0| */ sf:96b0bedd-3dbe-42c1-ade5-382aac333448:v1 | Add fpdf2 with limited HTML/CSS interpretation, opt-in shaping and complementary pypdf workflows. | attribution: /proposals/96b0bedd-3dbe-42c1-ade5-382aac333448