# fpdf2

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

ID: Q1133 · Revision: 1181

Type: software · License: LGPL\-3\.0\-only[^package] · Status: active

Website: https://py-pdf.github.io/fpdf2/



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\.[^home][^combine]

## 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\.[^home]

## 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\.[^html]

## 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\.[^shaping]

## 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\.[^combine]

## 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](/reportlabtoolkit) 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\.[^package][^home][^reportlab]

## Capabilities and substitutions

### Programmatic PDF generation — supported

Provides text, tables, images, drawing and automatic page breaks\.[^home]

Use case: Generating PDF documents from Python · Platforms: Python 3\.10\+; OS\-independent base · Region: Version, build and integration requirements apply

### HTML/CSS compatibility — limited

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

Use case: Generating PDF documents from Python · Platforms: Python 3\.10\+; OS\-independent base · Region: Version, build and integration requirements apply

### Complex text shaping — limited

Disabled by default, requires uharfbuzz and excludes Type 1 fonts\.[^shaping]

Use case: Generating PDF documents from Python · Platforms: Python 3\.10\+; OS\-independent base · Region: Version, build and integration requirements apply

### [Substitute for ReportLab Toolkit](/reportlabtoolkit) — limited

Can cover Python\-driven PDF generation; page\-layout APIs and template models require adaptation\.[^home][^reportlab]

Use case: Generating PDF documents from Python · Platforms: Python 3\.10\+; OS\-independent base · Region: Version, build and integration requirements apply

## References

[^home]: [fpdf2 documentation](<https://py-pdf.github.io/fpdf2/>) — Generation features and PyFPDF succession (vendor; retrieved 2026-10-07T12:40:16.084Z)

[^package]: [fpdf2 package metadata](<https://github.com/py-pdf/fpdf2/blob/master/pyproject.toml>) — LGPL\-3\.0\-only, Python 3\.10\+ and dependencies (vendor; retrieved 2026-10-07T12:40:16.084Z)

[^html]: [fpdf2 HTML input](<https://py-pdf.github.io/fpdf2/HTML.html>) — Basic HTML subset, styling exceptions and nesting limits (vendor; retrieved 2026-10-07T12:40:16.084Z)

[^shaping]: [fpdf2 text shaping](<https://py-pdf.github.io/fpdf2/TextShaping.html>) — Opt\-in uharfbuzz, font limitations and bidirectional text (vendor; retrieved 2026-10-07T12:40:16.084Z)

[^combine]: [Combining fpdf2 with pypdf](<https://py-pdf.github.io/fpdf2/CombineWithPypdf.html>) — Generated overlays, new pages and existing document manipulation (vendor; retrieved 2026-10-07T12:40:16.084Z)

[^reportlab]: [ReportLab Platypus](<https://docs.reportlab.com/reportlab/userguide/ch5_platypus/>) — Flow\-based Python PDF generation (vendor; retrieved 2026-10-07T12:40:16.084Z)

Source revision: https://substitutefor.net/entities/Q1133?revision=1181
