Registry / type-stubs / types-fpdf2

types-fpdf2

JSON →
library2.8.4.20260518pypypiunverified

This is a type stub package for the fpdf2 package, providing external type annotations for static analysis and type checking. It is part of the `typeshed` project and receives regular, often daily, automated releases to track changes in the upstream `fpdf2` library. This version of `types-fpdf2` aims to provide accurate annotations for `fpdf2==2.8.4`. Note that since `fpdf2` version 2.8.6, the `fpdf2` package itself includes type annotations, rendering `types-fpdf2` unnecessary for newer `fpdf2` versions.

pip install types-fpdf2
INSTALL
IMPORT
SIG · TYPES-FPDF2
T
types-fpdf2
type-stubspythonv2.8.4.20260518
Install
2.2s avg
Import
Disk
36MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.8.4.20260518 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.000s · 37.5MB
glibc
py 3.103.920 runs
installs and imports cleanly · install 2.2s · import 0.000s · 38MB
36MB installed
● package 36MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

FPDF
from fpdf_stubs import FPDF
from fpdf_stubs import FPDF

This quickstart demonstrates a minimal `fpdf2` usage. When `types-fpdf2` is installed in the same environment, type checkers like MyPy or Pyright will use its stubs to provide static analysis for your `fpdf2` code, ensuring type correctness and improving developer experience.

from fpdf import FPDF def create_pdf_document(filename: str = "hello_world.pdf") -> None: pdf: FPDF = FPDF() pdf.add_page() pdf.set_font("Helvetica", size=12) pdf.cell(200, 10, txt="Hello, world!", align="C") pdf.output(filename) print(f"PDF saved to {filename}") if __name__ == "__main__": create_pdf_document()
Debug
Known issues
gotchaIf you are using `fpdf2` version 2.8.6 or newer, `types-fpdf2` is not needed as `fpdf2` itself provides type annotations. Installing both may lead to redundant or conflicting type information, potentially causing unexpected type checking errors.
fix
Uninstall `types-fpdf2` if using `fpdf2` version 2.8.6 or newer (`pip uninstall types-fpdf2`).
affects: fpdf2 >= 2.8.6
gotcha`types-fpdf2` provides type hints for `fpdf2`'s font methods, but cannot guarantee that the fonts themselves support specific Unicode characters at runtime. If you're working with non-Latin characters, ensure you explicitly load a Unicode font with `pdf.add_font()` and set it with `pdf.set_font()` to avoid runtime `UnicodeEncodeError` exceptions.
fix
Explicitly add and set a TrueType font that supports the required Unicode range (e.g., `pdf.add_font(fname='path/to/my_unicode_font.ttf', uni=True)`).
affects: All
gotchaWhile `types-fpdf2` provides type hints for text rendering functions, `fpdf2` itself has known limitations with right-to-left (RTL) languages, particularly concerning automatic line breaking (`multi_cell`). Text direction and justification may not be handled correctly for all scripts.
fix
For complex RTL layouts, manual text arrangement or external pre-processing might be necessary. Consider checking `fpdf2`'s documentation or community forums for workarounds.
affects: All
Upgrade
Version history
2.8.4.20260518latest on PyPI · released May 18, 2026
Audit
Dependencies
fpdf2optionalProvides type hints for this runtime library. While not a hard runtime dependency, it is a logical dependency for the stubs to be useful.
Agent activity
29 hits · last 30 days
node
28
OpenAI (training)
1
Resources