Skip to content


Fork me on GitHub

fpdf2 is a library for PDF document generation in Python, forked from the unmaintained pyfpdf, itself ported from the PHP FPDF library.

Latest Released Version: Pypi latest version

fpdf2 logo

Main features

  • Easy to use (and easy to extend)
  • Small and compact code, useful for testing new features and teaching
  • Many simple examples and scripts available in many languages
  • PIL Integration for images (via Pillow)
  • No installation, no compilation or other libraries (DLLs) required

This repository is a fork of the library's original port by Max Pat, with the following enhancements:

  • Python 3.6+ support
  • Unicode (UTF-8) TrueType font subset embedding (Central European, Cyrillic, Greek, Baltic, Thai, Chinese, Japanese, Korean, Hindi and almost any other language in the world)
  • PNG, GIF and JPG support (including transparency and alpha channel)
  • Shape, Line Drawing
  • Generate Code 39 & Interleaved 2 of 5 barcodes
  • Cell / multi-cell / plaintext writing, automatic page breaks
  • Basic conversion from HTML to PDF
  • Images & links alternative descriptions
  • Table of contents & document outline
  • Optional basic Markdown-like styling: **bold**, __italics__, --underlined--
  • Clean error handling through exceptions
  • Only one dependency so far: Pillow
  • Unit tests with qpdf-based PDF diffing
  • PDF samples validation using 3 different checkers:

QPDF logo PDF Checker logo VeraPDF logo

FPDF original features:

  • Choice of measurement unit, page format and margins
  • Page header and footer management
  • Automatic page break, line break and text justification
  • Image, colors and links support
  • Page compression


  • From PyPI: pip install fpdf2
  • From source:
    • Clone the repository: git clone
    • On ubuntu the following packages are required: sudo apt-get install libjpeg-dev libpython-dev zlib1g-dev # libpython3.3-dev #(if necessary)
    • Run python install


For community support, please feel free to file an issue.