skillfed

fpdf2

Simple & fast PDF generation for Python

fpdf2 v2.8.8 19.1M downloads/30d#1,074 on PyPI1,535
Copyleft license LGPL-3.0-only Active released

What it is and what it does

fpdf2 is a pure-Python PDF generation library that lets you build PDF documents programmatically by adding pages, text, images, tables, and other content. It handles Unicode text with TrueType font embedding, supports internal and external links, can embed images with transparency, and includes features like barcodes, charts, document encryption, and basic HTML conversion. The library depends on Pillow for image handling, fonttools for font subsetting, and defusedxml for safe XML parsing.

It's designed to be fast and easy to learn, with a straightforward API: create a FPDF object, add pages, set fonts, write content, and output to a file. The project is mature and actively maintained, supporting Python 3.10 and later. It includes over 1300 unit tests and is widely used in web applications.

Use it for:

  • Generate invoices, receipts, or reports on-the-fly in web applications without external services.
  • Batch-create templated PDFs (certificates, letters, forms) from data using the templating system.
  • Embed images, barcodes, or charts into dynamically generated documents.
  • Convert HTML content to PDF for archival or distribution.
  • Add document encryption or digital signatures for secure PDF delivery.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

fpdf2 generates PDF documents programmatically in Python, supporting text, images, tables, barcodes, and basic HTML conversion with Unicode font embedding.

Yes. fpdf2 is a mature, actively maintained library with low install friction (three lightweight dependencies), no known vulnerabilities, and broad Python version support (3.10+). It's well-suited for straightforward PDF generation tasks. The LGPL-3.0 copyleft license requires that derivative works remain open-source, which is a consideration for proprietary projects but not a barrier for most use cases.

Install

fpdf2 on PyPI

pip

pip install fpdf2

uv

uv add fpdf2

poetry

poetry add fpdf2

Installing fpdf2

Before you install

Low friction: pure Python with only three runtime dependencies. Actively maintained with a release 5 days ago and 1535 GitHub stars.

License in practice

LGPL-3.0-only (copyleft): you may use and modify fpdf2 freely, but derivative works must also be licensed under LGPL-3.0 and source code must be available to users.

Quickstart

pip install fpdf2

from fpdf import FPDF

pdf = FPDF()
pdf.add_page()
pdf.set_font('helvetica', size=12)
pdf.cell(text="hello world")
pdf.output("hello_world.pdf")

Verify before relying

  • Whether the library's performance characteristics (speed, memory usage) meet your specific document size or throughput requirements.
  • Whether HTML-to-PDF conversion handles your particular HTML/CSS subset adequately.
  • Specific use-case compatibility with Django, Flask, FastAPI, or other frameworks mentioned in the description.

Package facts

License LGPL-3.0-only (copyleft)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 3 — defusedxml, Pillow, fonttools
Maintenance actively maintained — 5 days since the last release
Last repo commit
First released
Downloads 19,110,259/month — #1,074 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: fpdf2-2.8.8-py3-none-any.whl

Keywords: pdf, unicode, png, jpg, ttf, barcode, library, markdown

Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Multimedia :: GraphicsTopic :: Multimedia :: Graphics :: PresentationTopic :: PrintingTopic :: Software Development :: Libraries :: Python ModulesTopic :: Text Processing :: Markup

Tags

python pdf generation librarycreate pdf from pythonpdf writer unicode fontsgenerate pdf documents pythonpdf creation with tables and imagespython pdf with barcodeslightweight pdf library python
pdf-generationdocument-creation

More Python Modules packages