https://py-pdf.github.io/fpdf2/
Simple PDF generation for Python
https://py-pdf.github.io/fpdf2/
barcode hacktoberfest library markdown pdf pdf-generation pdf-library python python3 svg
Last synced: 3 months ago
JSON representation
Simple PDF generation for Python
- Host: GitHub
- URL: https://py-pdf.github.io/fpdf2/
- Owner: py-pdf
- License: lgpl-3.0
- Fork: true (reingart/pyfpdf)
- Created: 2017-03-15T15:31:54.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-07-24T00:21:34.000Z (4 months ago)
- Last Synced: 2025-07-24T03:21:58.378Z (4 months ago)
- Topics: barcode, hacktoberfest, library, markdown, pdf, pdf-generation, pdf-library, python, python3, svg
- Language: Python
- Homepage: https://py-pdf.github.io/fpdf2/
- Size: 377 MB
- Stars: 1,317
- Watchers: 20
- Forks: 283
- Open Issues: 64
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
- awesome-python - py-pdf.github.io/fpdf2
README
[](https://pypi.org/pypi/fpdf2#history)
[](https://pypi.org/project/fpdf2/)
[](https://www.gnu.org/licenses/lgpl-3.0)
[](https://github.com/py-pdf/fpdf2/actions?query=branch%3Amaster)
[](https://codecov.io/gh/py-pdf/fpdf2)
[](https://blog.pypi.org/posts/2023-04-20-introducing-trusted-publishers/)
[](https://github.com/py-pdf/fpdf2/actions/workflows/continuous-integration-workflow.yml)
[](https://libraries.io/pypi/fpdf2/dependents)
[](https://pepy.tech/project/fpdf2)
[](https://github.com/py-pdf/fpdf2/graphs/contributors)
[](https://github.com/py-pdf/fpdf2/commits/master)
[](https://github.com/py-pdf/fpdf2/issues)
[](https://github.com/py-pdf/fpdf2/pulls)
[](http://makeapullrequest.com)
[](http://www.firsttimersonly.com/)
โ come look at our [good first issues](https://github.com/py-pdf/fpdf2/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
# fpdf2

`fpdf2` is a PDF creation library for Python:
```python
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: [](https://colab.research.google.com/github/py-pdf/fpdf2/blob/master/tutorial/notebook.ipynb) or [](https://nbviewer.org/github/py-pdf/fpdf2/blob/master/tutorial/notebook.ipynb)
Compared with other PDF libraries, `fpdf2` is **fast, versatile, easy to learn and to extend** ([example](https://github.com/digidigital/Extensions-and-Scripts-for-pyFPDF-fpdf2)).
It is also entirely written in Python and has very few dependencies:
[Pillow](https://pillow.readthedocs.io/en/stable/), [defusedxml](https://pypi.org/project/defusedxml/), & [fontTools](https://fonttools.readthedocs.io/en/latest/index.html). It is a fork and the successor of `PyFPDF` (_cf._ [history](https://py-pdf.github.io/fpdf2/History.html)).
**Development status**: this project is **mature** and **actively maintained**.
We are looking for contributing developers: if you want to get involved but don't know how,
or would like to volunteer helping maintain this lib, [open a discussion](https://github.com/py-pdf/fpdf2/discussions)!
## Installation Instructions
```bash
pip install fpdf2
```
To get the latest, unreleased, development version straight from the development branch of this repository:
```bash
pip install git+https://github.com/py-pdf/fpdf2.git@master
```
## Features
* Python 3.8+ support
* [Unicode](https://py-pdf.github.io/fpdf2/Unicode.html) (UTF-8) TrueType font subset embedding
* Internal / external [links](https://py-pdf.github.io/fpdf2/Links.html)
* Embedding images, including transparency and alpha channel
* Arbitrary path drawing and basic [SVG](https://py-pdf.github.io/fpdf2/SVG.html) import
* Embedding [barcodes](https://py-pdf.github.io/fpdf2/Barcodes.html), [charts & graphs](https://py-pdf.github.io/fpdf2/Maths.html), [emojis, symbols & dingbats](https://py-pdf.github.io/fpdf2/EmojisSymbolsDingbats.html)
* [Tables](https://py-pdf.github.io/fpdf2/Tables.html) and also [cell / multi-cell / plaintext writing](https://py-pdf.github.io/fpdf2/Text.html), with [automatic page breaks](https://py-pdf.github.io/fpdf2/PageBreaks.html), line break and text justification
* Choice of measurement unit, page format & margins. Optional page header and footer
* Basic [conversion from HTML to PDF](https://py-pdf.github.io/fpdf2/HTML.html)
* A [templating system](https://py-pdf.github.io/fpdf2/Templates.html) to render PDFs in batches
* Images & links alternative descriptions, for accessibility
* Table of contents & [document outline](https://py-pdf.github.io/fpdf2/DocumentOutlineAndTableOfContents.html)
* [Document encryption](https://py-pdf.github.io/fpdf2/Encryption.html) & [document signing](https://py-pdf.github.io/fpdf2/Signing.html)
* [Annotations](https://py-pdf.github.io/fpdf2/Annotations.html), including text highlights, and [file attachments](https://py-pdf.github.io/fpdf2/FileAttachments.html)
* [Presentation mode](https://py-pdf.github.io/fpdf2/Presentations.html) with control over page display duration & transitions
* Optional basic Markdown-like styling: `**bold**, __italics__`
* Can render [mathematical equations & charts](https://py-pdf.github.io/fpdf2/Maths.html)
* Usage examples with [Django](https://www.djangoproject.com/), [Flask](https://flask.palletsprojects.com), [FastAPI](https://fastapi.tiangolo.com/), [streamlit](https://streamlit.io/), AWS lambdas... : [Usage in web APIs](https://py-pdf.github.io/fpdf2/UsageInWebAPI.html)
* more than 1300 unit tests running under Linux & Windows, with `qpdf`-based PDF diffing, timing & memory usage checks, and a high code coverage
Our 350+ reference PDF test files, generated by `fpdf2`, are validated using 3 different checkers:
[](https://github.com/qpdf/qpdf)
[](https://www.datalogics.com/repair-pdf-files)
[](https://verapdf.org)
## Please show the value
Choosing a project dependency can be difficult. We need to ensure stability and maintainability of our projects.
Surveys show that GitHub stars count play an important factor when assessing library quality.
โญ Please give this repository a star. It takes seconds and will help your fellow developers! โญ
## Please share with the community
This library relies on community interactions. Please consider sharing a post about `fpdf2` and the value it provides ๐
[](https://reddit.com/submit?url=https://github.com/py-pdf/fpdf2&title=fpdf2)
[](https://news.ycombinator.com/submitlink?u=https://github.com/py-pdf/fpdf2)
[](https://twitter.com/share?url=https://github.com/py-pdf/fpdf2&t=fpdf2)
[](https://www.facebook.com/sharer/sharer.php?u=https://github.com/py-pdf/fpdf2)
[](https://www.linkedin.com/shareArticle?url=https://github.com/py-pdf/fpdf2&title=fpdf2)
## Documentation
- [Documentation Home](https://py-pdf.github.io/fpdf2/)
- Tutorial in several languages: [English](https://py-pdf.github.io/fpdf2/Tutorial.html) - [Deutsch](https://py-pdf.github.io/fpdf2/Tutorial-de.html) - [espaรฑol](https://py-pdf.github.io/fpdf2/Tutorial-es.html) - [เคนเคฟเคเคฆเฅ](https://py-pdf.github.io/fpdf2/Tutorial-hi.html) - [portuguรชs](https://py-pdf.github.io/fpdf2/Tutorial-pt.html) - [ะ ัััะบะธะน](https://py-pdf.github.io/fpdf2/Tutorial-ru.html) - [Italian](https://py-pdf.github.io/fpdf2/Tutorial-it.html) - [franรงais](https://py-pdf.github.io/fpdf2/Tutorial-fr.html) - [ฮฮปฮปฮทฮฝฮนฮบฮฌ](https://py-pdf.github.io/fpdf2/Tutorial-gr.html) - [ืขืืจืืช](https://py-pdf.github.io/fpdf2/Tutorial-he.html) - [็ฎไฝไธญๆ](https://py-pdf.github.io/fpdf2/Tutorial-zh.html) - [เฆฌเฆพเฆเฆฒเฆพ](https://py-pdf.github.io/fpdf2/Tutorial-bn.html) - [แแถแแถแแแแแ](https://py-pdf.github.io/fpdf2/Tutorial-km.html) - [ๆฅๆฌ่ช](https://py-pdf.github.io/fpdf2/Tutorial-ja.html) - [Dutch](https://py-pdf.github.io/fpdf2/Tutorial-nl.html) - [Polski](https://py-pdf.github.io/fpdf2/Tutorial-pl.html) - [Tรผrkรงe](https://py-pdf.github.io/fpdf2/Tutorial-tr.html) - [Indonesian](https://py-pdf.github.io/fpdf2/Tutorial-id.html)- [Slovenลกฤina](https://py-pdf.github.io/fpdf2/Tutorial-sl.html)
- Release notes: [CHANGELOG.md](https://github.com/py-pdf/fpdf2/blob/master/CHANGELOG.md)
- A series of blog posts: [fpdf2 tag @ ludochaordic](https://chezsoi.org/lucas/blog/tag/fpdf2.html)
You can also have a look at the `tests/`, they're great usage examples!
## Development
Please check the [dedicated documentation page](https://py-pdf.github.io/fpdf2/Development.html).
## Contributors โจ
This library could only exist thanks to the dedication of many volunteers around the world:

Mariano Reingart
๐ป

David Ankin
๐ ๐ป ๐ ๐ง ๐ฌ ๐ โ ๏ธ

Alex Pavlovich
๐ ๐ป ๐ ๐ฌ ๐ โ ๏ธ

Lucas Cimon
๐ ๐ป ๐ ๐ ๐ง ๐ฌ ๐

Miroslav ล edivรฝ
๐ป โ ๏ธ

Florian Bernhart
๐ป โ ๏ธ

Edwood Ocasio
๐ป โ ๏ธ

Marcelo Duarte
๐ป

Roman Kharin
๐ป ๐ค

Christopher Frost
๐ ๐ป

Michael Kalbermatten
๐ ๐ป

Yanone
๐ป

Leo Zhu
๐ป

Abishek Goda
๐ป

Arthur Moore
๐ป โ ๏ธ ๐

Bogdan Cuza
๐ป

Craig Hobbs
๐ป

xitrushiy
๐ ๐ป

Josรฉ L. Redrejo Rodrรญguez
๐ป

Jรผrgen Gmach
๐ป

Larivact
๐ป

Leonel Cรขmara
๐ป

Mark Steadman
๐ ๐ป

Sergey
๐ป

Stan-C421
๐ป

Viraj Shah
๐ป

cornicis
๐ป

moe-25
๐ป ๐ ๐ฌ ๐

Simone Bizzotto
๐ป

Boonyawe Sirimaha
๐

T
๐ป ๐จ

AubsUK
๐ฌ

Georg Mischler
๐ ๐ป ๐จ ๐ ๐ค ๐ฌ โ ๏ธ

ping
๐

Portfedh
๐ โ

Tabarnhack
๐ป

Mridul Birla
๐

digidigital
๐

Xit
๐

Alexander Burchenko
๐

Andrรฉ Assunรงรฃo
๐

Quentin Brault
๐

Paula Campigotto
๐ ๐ป ๐

bettman-latin
๐ป

oleksii-shyman
๐ป ๐จ ๐ค

lcomrade
๐ ๐ ๐ป

pwt
๐ ๐ป

Martin Cerveny
๐ ๐ป

Spenhouet
๐ ๐

mtkumar123
๐ป

Davide Consalvo
๐ป ๐ฌ ๐จ

Bruno Santos
๐

cgkoutzigiannis
โ ๏ธ

I Wayan Kurniawan
๐

Sven Eliasson
๐

gonzalobarbaran
๐ป

Nuttapat Koonarangsri
๐ ๐

Sokratis Vasiliou
๐

semaeostomea
๐ ๐ป

Josuรฉ Millรกn Zamora
๐ป

me-suzy
๐

dmail00
๐ ๐ป

Gerardo Allende
๐ป ๐ฌ

Nicholas Jin
๐

Yusuke
๐ป

Tillrzhtgrfho
๐

Dario Ackermann
๐

Tzvi Greenfeld
๐ ๐

devdev29
๐ ๐ป

Johan Bonneau
๐

Jesรบs Alberto Muรฑoz Mesa
โ ๏ธ ๐ ๐

Jaydeep Das
๐ฌ

Sean
๐ป

Anderson Herzogenrath da Costa
๐ฌ ๐ป ๐ฌ ๐ ๐ ๐ค ๐ง

Yi Wei Lan
โ ๏ธ

CpDong
๐ป ๐ ๐

CY-Qiu
๐

Markovvn1
๐ป

Elad Rapaport
๐ป

SfinxV
๐

bramantoleksono
๐

TheNerdy907
๐

Elie Roux
๐ ๐ค ๐ป ๐ฌ

msalem
๐

Manuel Ruiz
๐

Noel
๐

Avik Sarkar
๐ ๐ ๐ฌ

aeris07
๐

KamarulAdha
๐

Valerus5685
๐

Sebastian Tia
๐ป

Eugene Selifonov
๐

Kuth
๐

Ruben de Bruin
๐ ๐ป ๐

stenci
๐

alcnaka
๐

Tolker-KU
๐ป

lfavole
๐ป

Nicolai Wolfrom
๐

Sandra
๐ค ๐ป

navitho
๐

Sai Harsha Kottapalli
๐ป

Rakesh N J
๐

rodos
๐

Ted Brookings
๐ป

Andy Friedman
๐ป

Matt
๐

matipos2
๐

lry12138
๐

Martijn Jasperse
๐ ๐ป

demiurgepy
๐

Marek Tovlin
๐ป

Polderrider
๐

Elena ``of Valhalla''
โ ๏ธ

Niall O'Callaghan
๐

jsid72
๐

Alan Collins
๐ป

hyperstown
๐

Clock-Speed
๐ป

Darek
๐

Carl Higgs
๐ป

awmc000
๐ป

Scott Smitelli
๐

lcgeneralprojects
๐ ๐ป

Christopher Lane
๐ โ ๏ธ

David
๐ป

Sezer Bozkฤฑr
๐

Odhy Pradhana
๐

Li
๐

Matthias Schoettle
๐ ๐

Steve Simmons
๐

Joรฃo Henrique
๐

Bernhard Miklautz
๐

Bryn Jeffries
๐

Benoit Charbonneau
๐ค

Philip Jones
๐

opposss
๐ป

Dat Le
๐ ๐ป

Kaustubh
๐ป

Derek Robinson
๐

Kevin Castro
๐

jasonfevangsafe
๐ ๐ ๐ป

visheshdvivedi
๐ป

petri-lipponen-movesense
๐ป

Soomin Choi
๐ป

Black-Hole
๐

lka
๐ป ๐ ๐ค โ

andreaswimmer
๐

Mercuron
๐ป

yuyiz67
๐ป

Rob
๐

Tobias Kรคs
๐

Chi Kim
๐

Peter Suter
๐

slkoo-core
๐

Eshani
๐

Pratyush
๐
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification
([emoji key](https://allcontributors.org/docs/en/emoji-key)).
Contributions of any kind welcome!
[](https://py-pdf.github.io/fpdf2/contributors.html)
_(screenshot from January 2023, click on the map above to access an up-to-date online version)_
## Community, related tools, alternative libraries
More about those in [the documentation](https://py-pdf.github.io/fpdf2/#community).