Skip to content

fpdf2

Fork me on GitHub

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(txt="hello world")
pdf.output("hello_world.pdf")

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/PyFPDF/fpdf2.git@master

fpdf2 can be installed without any dependency, but it needs Pillow to render images:

pip install --no-dependencies fpdf2

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

  • 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

Misc