Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: about 1 month ago
JSON representation

Simple PDF generation for Python

Awesome Lists containing this project

README

        

[![Pypi latest version](https://img.shields.io/pypi/v/fpdf2.svg)](https://pypi.org/pypi/fpdf2#history)
[![Python Support](https://img.shields.io/pypi/pyversions/fpdf2.svg)](https://pypi.org/project/fpdf2/)
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)

[![build status](https://github.com/py-pdf/fpdf2/workflows/build/badge.svg)](https://github.com/py-pdf/fpdf2/actions?query=branch%3Amaster)
[![codecov](https://codecov.io/gh/py-pdf/fpdf2/branch/master/graph/badge.svg)](https://codecov.io/gh/py-pdf/fpdf2)
![security: bandit, pylint, semgrep](https://img.shields.io/badge/linters-bandit,pylint,semgrep-yellow.svg)

[![Dependents](https://img.shields.io/librariesio/dependents/pypi/fpdf2)](https://libraries.io/pypi/fpdf2/dependents)
[![Downloads per month](https://pepy.tech/badge/fpdf2/month)](https://pepy.tech/project/fpdf2)
[![Contributors](https://img.shields.io/github/contributors/py-pdf/fpdf2)](https://github.com/py-pdf/fpdf2/graphs/contributors)
[![GitHub last commit](https://img.shields.io/github/last-commit/py-pdf/fpdf2)](https://github.com/py-pdf/fpdf2/commits/master)

[![issues closed](https://img.shields.io/github/issues-closed/py-pdf/fpdf2)](https://github.com/py-pdf/fpdf2/issues)
[![PRs closed](https://img.shields.io/github/issues-pr-closed/py-pdf/fpdf2)](https://github.com/py-pdf/fpdf2/pulls)
[![Pull Requests Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)](http://makeapullrequest.com)
[![first-timers-only Friendly](https://img.shields.io/badge/first--timers--only-friendly-blue.svg)](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 logo](https://py-pdf.github.io/fpdf2/fpdf2-logo.png)

`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: [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/py-pdf/fpdf2/blob/master/tutorial/notebook.ipynb) or [![Open In nbviewer](https://img.shields.io/badge/Open_In-nbviewer-blue?logo=jupyter)](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.7+ 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:

[![QPDF logo](https://py-pdf.github.io/fpdf2/qpdf-logo.svg)](https://github.com/qpdf/qpdf)
[![PDF Checker logo](https://py-pdf.github.io/fpdf2/pdfchecker-logo.png)](https://www.datalogics.com/products/pdf-tools/pdf-checker/)
[![VeraPDF logo](https://py-pdf.github.io/fpdf2/vera-logo.jpg)](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 ๐Ÿ˜Š

[![GitHub Repo stars](https://img.shields.io/badge/share%20on-reddit-red?logo=reddit)](https://reddit.com/submit?url=https://github.com/py-pdf/fpdf2&title=fpdf2)
[![GitHub Repo stars](https://img.shields.io/badge/share%20on-hacker%20news-orange?logo=ycombinator)](https://news.ycombinator.com/submitlink?u=https://github.com/py-pdf/fpdf2)
[![GitHub Repo stars](https://img.shields.io/badge/share%20on-twitter-03A9F4?logo=twitter)](https://twitter.com/share?url=https://github.com/py-pdf/fpdf2&t=fpdf2)
[![GitHub Repo stars](https://img.shields.io/badge/share%20on-facebook-1976D2?logo=facebook)](https://www.facebook.com/sharer/sharer.php?u=https://github.com/py-pdf/fpdf2)
[![GitHub Repo stars](https://img.shields.io/badge/share%20on-linkedin-3949AB?logo=linkedin)](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)
- 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
Mariano Reingart

๐Ÿ’ป
David Ankin
David Ankin

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿšง ๐Ÿ’ฌ ๐Ÿ‘€ โš ๏ธ
Alex Pavlovich
Alex Pavlovich

๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ฌ ๐Ÿ‘€ โš ๏ธ
Lucas Cimon
Lucas Cimon

๐Ÿ“ ๐Ÿ’ป ๐Ÿ“– ๐Ÿš‡ ๐Ÿšง ๐Ÿ’ฌ ๐Ÿ›
Miroslav ล edivรฝ
Miroslav ล edivรฝ

๐Ÿ’ป โš ๏ธ
Florian Bernhart
Florian Bernhart

๐Ÿ’ป โš ๏ธ
Edwood Ocasio
Edwood Ocasio

๐Ÿ’ป โš ๏ธ


Marcelo Duarte
Marcelo Duarte

๐Ÿ’ป
Roman Kharin
Roman Kharin

๐Ÿ’ป ๐Ÿค”
Christopher Frost
Christopher Frost

๐Ÿ› ๐Ÿ’ป
Michael Kalbermatten
Michael Kalbermatten

๐Ÿ› ๐Ÿ’ป
Yanone
Yanone

๐Ÿ’ป
Leo Zhu
Leo Zhu

๐Ÿ’ป
Abishek Goda
Abishek Goda

๐Ÿ’ป


Arthur Moore
Arthur Moore

๐Ÿ’ป โš ๏ธ ๐Ÿ›
Bogdan Cuza
Bogdan Cuza

๐Ÿ’ป
Craig Hobbs
Craig Hobbs

๐Ÿ’ป
xitrushiy
xitrushiy

๐Ÿ› ๐Ÿ’ป
Josรฉ L. Redrejo Rodrรญguez
Josรฉ L. Redrejo Rodrรญguez

๐Ÿ’ป
Jรผrgen Gmach
Jรผrgen Gmach

๐Ÿ’ป
Larivact
Larivact

๐Ÿ’ป


Leonel Cรขmara
Leonel Cรขmara

๐Ÿ’ป
Mark Steadman
Mark Steadman

๐Ÿ› ๐Ÿ’ป
Sergey
Sergey

๐Ÿ’ป
Stan-C421
Stan-C421

๐Ÿ’ป
Viraj Shah
Viraj Shah

๐Ÿ’ป
cornicis
cornicis

๐Ÿ’ป
moe-25
moe-25

๐Ÿ’ป ๐Ÿ‘€ ๐Ÿ”ฌ ๐Ÿ›


Simone Bizzotto
Simone Bizzotto

๐Ÿ’ป
Boonyawe Sirimaha
Boonyawe Sirimaha

๐Ÿ›
T
T

๐Ÿ’ป ๐ŸŽจ
AubsUK
AubsUK

๐Ÿ’ฌ
Georg Mischler
Georg Mischler

๐Ÿ› ๐Ÿ’ป ๐ŸŽจ ๐Ÿ“– ๐Ÿค” ๐Ÿ’ฌ โš ๏ธ
ping
ping

๐Ÿ›
Portfedh
Portfedh

๐Ÿ“– โœ…


Tabarnhack
Tabarnhack

๐Ÿ’ป
Mridul Birla
Mridul Birla

๐ŸŒ
digidigital
digidigital

๐ŸŒ
Xit
Xit

๐ŸŒ
Alexander Burchenko
Alexander Burchenko

๐ŸŒ
Andrรฉ Assunรงรฃo
Andrรฉ Assunรงรฃo

๐ŸŒ
Quentin Brault
Quentin Brault

๐ŸŒ


Paula Campigotto
Paula Campigotto

๐Ÿ› ๐Ÿ’ป ๐Ÿ‘€
bettman-latin
bettman-latin

๐Ÿ’ป
oleksii-shyman
oleksii-shyman

๐Ÿ’ป ๐ŸŽจ ๐Ÿค”
lcomrade
lcomrade

๐Ÿ“– ๐Ÿ› ๐Ÿ’ป
pwt
pwt

๐Ÿ› ๐Ÿ’ป
Martin Cerveny
Martin Cerveny

๐Ÿ› ๐Ÿ’ป
Spenhouet
Spenhouet

๐Ÿ› ๐Ÿ‘€


mtkumar123
mtkumar123

๐Ÿ’ป
Davide Consalvo
Davide Consalvo

๐Ÿ’ป ๐Ÿ’ฌ ๐ŸŽจ
Bruno Santos
Bruno Santos

๐Ÿ›
cgkoutzigiannis
cgkoutzigiannis

โš ๏ธ
I Wayan Kurniawan
I Wayan Kurniawan

๐Ÿ“–
Sven Eliasson
Sven Eliasson

๐Ÿ“–
gonzalobarbaran
gonzalobarbaran

๐Ÿ’ป


Nuttapat Koonarangsri
Nuttapat Koonarangsri

๐Ÿ“– ๐Ÿ›
Sokratis Vasiliou
Sokratis Vasiliou

๐ŸŒ
semaeostomea
semaeostomea

๐Ÿ“– ๐Ÿ’ป
Josuรฉ Millรกn Zamora
Josuรฉ Millรกn Zamora

๐Ÿ’ป
me-suzy
me-suzy

๐Ÿ›
dmail00
dmail00

๐Ÿ› ๐Ÿ’ป
Gerardo Allende
Gerardo Allende

๐Ÿ’ป ๐Ÿ”ฌ


Nicholas Jin
Nicholas Jin

๐Ÿ›
Yusuke
Yusuke

๐Ÿ’ป
Tillrzhtgrfho
Tillrzhtgrfho

๐Ÿ›
Dario Ackermann
Dario Ackermann

๐Ÿ›
Tzvi Greenfeld
Tzvi Greenfeld

๐Ÿ“– ๐ŸŒ
devdev29
devdev29

๐Ÿ“– ๐Ÿ’ป
Johan Bonneau
Johan Bonneau

๐Ÿ“–


Jesรบs Alberto Muรฑoz Mesa
Jesรบs Alberto Muรฑoz Mesa

โš ๏ธ ๐Ÿ“– ๐ŸŒ
Jaydeep Das
Jaydeep Das

๐Ÿ’ฌ
Sean
Sean

๐Ÿ’ป
Anderson Herzogenrath da Costa
Anderson Herzogenrath da Costa

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿ”ฌ ๐Ÿ› ๐Ÿ“– ๐Ÿค”
Yi Wei Lan
Yi Wei Lan

โš ๏ธ
CpDong
CpDong

๐Ÿ’ป ๐Ÿ› ๐ŸŒ
CY-Qiu
CY-Qiu

๐Ÿ›


Markovvn1
Markovvn1

๐Ÿ’ป
Elad Rapaport
Elad Rapaport

๐Ÿ’ป
SfinxV
SfinxV

๐Ÿ›
bramantoleksono
bramantoleksono

๐Ÿ›
TheNerdy907
TheNerdy907

๐Ÿ›
Elie Roux
Elie Roux

๐Ÿ› ๐Ÿค” ๐Ÿ’ป ๐Ÿ’ฌ
msalem
msalem

๐Ÿ“–


Manuel Ruiz
Manuel Ruiz

๐Ÿ›
Noel
Noel

๐Ÿ›
Avik Sarkar
Avik Sarkar

๐ŸŒ ๐Ÿ“– ๐Ÿ’ฌ
aeris07
aeris07

๐Ÿ›
KamarulAdha
KamarulAdha

๐Ÿ“–
Valerus5685
Valerus5685

๐Ÿ›
Sebastian Tia
Sebastian Tia

๐Ÿ’ป


Eugene Selifonov
Eugene Selifonov

๐Ÿ›
Kuth
Kuth

๐ŸŒ
Ruben de Bruin
Ruben de Bruin

๐Ÿ› ๐Ÿ’ป ๐Ÿ“–
stenci
stenci

๐Ÿ›
alcnaka
alcnaka

๐ŸŒ
Tolker-KU
Tolker-KU

๐Ÿ’ป
lfavole
lfavole

๐Ÿ’ป


Nicolai Wolfrom
Nicolai Wolfrom

๐Ÿ›
Sandra
Sandra

๐Ÿค” ๐Ÿ’ป
navitho
navitho

๐Ÿ›
Sai Harsha Kottapalli
Sai Harsha Kottapalli

๐Ÿ’ป
Rakesh N J
Rakesh N J

๐Ÿ“–
rodos
rodos

๐Ÿ›
Ted Brookings
Ted Brookings

๐Ÿ’ป


Andy Friedman
Andy Friedman

๐Ÿ’ป
Matt
Matt

๐Ÿ“–
matipos2
matipos2

๐Ÿ“–
lry12138
lry12138

๐ŸŒ
Martijn Jasperse
Martijn Jasperse

๐Ÿ› ๐Ÿ’ป
demiurgepy
demiurgepy

๐Ÿ›
Marek Tovlin
Marek Tovlin

๐Ÿ’ป


Polderrider
Polderrider

๐ŸŒ
Elena ``of Valhalla''
Elena ``of Valhalla''

โš ๏ธ
Niall O'Callaghan
Niall O'Callaghan

๐Ÿ›
jsid72
jsid72

๐Ÿ›
Alan Collins
Alan Collins

๐Ÿ’ป
hyperstown
hyperstown

๐Ÿ–‹
Clock-Speed
Clock-Speed

๐Ÿ’ป


Darek
Darek

๐ŸŒ
Carl Higgs
Carl Higgs

๐Ÿ’ป
awmc000
awmc000

๐Ÿ’ป
Scott Smitelli
Scott Smitelli

๐Ÿ›
lcgeneralprojects
lcgeneralprojects

๐Ÿ› ๐Ÿ’ป
Christopher Lane
Christopher Lane

๐Ÿ“– โš ๏ธ
David
David

๐Ÿ’ป


Sezer Bozkฤฑr
Sezer Bozkฤฑr

๐ŸŒ

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!

[![Contributors map](https://py-pdf.github.io/fpdf2/contributors-map-small.png)](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).