Skip to content

fpdf2

fpdf2 is a library for simple & fast PDF document generation in Python. It is a fork and the successor of PyFPDF (cf. history).

Latest Released Version: Pypi latest version

fpdf2 logo

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

Go try it now online in a Jupyter notebook: Open In Colab or Open In nbviewer

Main features

QPDF logo PDF Checker logo VeraPDF logo

Tutorials

Installation

From PyPI:

pip install fpdf2

To get the latest, unreleased, development version straight from the development branch of this repository:

pip install git+https://github.com/py-pdf/fpdf2.git@master

Developement: check the dedicated documentation page.

Displaying deprecation warnings

DeprecationWarnings are not displayed by Python by default.

Hence, every time you use a newer version of fpdf2, we strongly encourage you to execute your scripts with the -Wd option (cf. documentation) in order to get warned about deprecated features used in your code.

This can also be enabled programmatically with warnings.simplefilter('default', DeprecationWarning).

Community

Support

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

They use fpdf2

  • Harvard University uses fpdf2 in their CS50 introductory class
  • 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
  • wudududu/extract-video-ppt : create a one-page-per-frame PDF from a video or PPT file. fpdf2 also has a demo script to convert a GIF into a one-page-per-frame PDF: gif2pdf.py
  • csv2pdf : convert CSV files to PDF files easily
  • Planet-Matriarchy-RPG-CharGen : a PyQt based desktop application (= .exe under Windows) that provides a RPG character sheet generator

Usage statistics

Star history

Misc