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
    • Run python install

Developement: check the dedicated documentation page.



For community support, please feel free to file an issue or open a discussion.

They use fpdf2

  • Undying Dusk : a video game in PDF format, with a gameplay based on exploration and logic puzzles, in the tradition of dungeon crawlers
  • OpenDroneMap : a command line toolkit for processing aerial drone imagery
  • OpenSfM : a Structure from Motion library, serving as a processing pipeline for reconstructing camera poses and 3D scenes from multiple images
  • RPA Framework : libraries and tools for Robotic Process Automation (RPA), designed to be used with both Robot Framework
  • Concordia : a platform developed by the US Library of Congress for crowdsourcing transcription and tagging of text in digitized images
  • GovReady-Q Compliance Server : GRC platform for highly automated, user-friendly, self-service compliance assessments and documentation (DevSecOps)
  • csv2pdf : convert CSV files to PDF files easily