Typing Stubs for fpdf2

2.8.4.20260408 · active · verified Tue Apr 14

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.

Warnings

Install

Imports

Quickstart

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()

view raw JSON →