This article will present some of the major features introduced between v2.5.3 & v2.7.3 of
- Images & shapes
- Fonts & text
- Signing & encrypting documents
- Documentation & translated tutorials
- What's coming next?
One major addition of v2.7.0 of
fpdf2 has the new method
that now makes very easy the generation of tables in PDF documents.
We documented how to use this method in a dedicated documentation page: https://pyfpdf.github.io/fpdf2/Tables.html
Here is some snippet of demo code:
from fpdf import FPDF TABLE_DATA = ( ("First name", "Last name", "Age", "City"), ... ) pdf = FPDF() pdf.add_page() pdf.set_font("Helvetica", size=16) with pdf.table(borders_layout="MINIMAL", col_widths=(30, 30, 10, 30), cell_fill_color=200, # grey scale cell_fill_mode="ROWS", text_align="CENTER") as table: for data_row in TABLE_DATA: row = table.row() for datum in data_row: row.cell(datum) pdf.output("table-demo.pdf")
And the result:
Images & shapes
There has been several new features related to images:
FPDF.image()has two new optional parameters:
align="C"to horizontally an image on a page, and
keep_aspect_ratiowhich allows to preserve an image ratio. Related documentation section: fitting an image inside a rectangle.
we documentated on how to control transparency of overlapping text, shapes and images through
Fonts & text
fpdf2now uses the popular fontTools library to read and embed fonts in the PDF. This extended the range of font definition files supported by
fpdf2, and also made the code used to parse & insert fonts a lot more robust. Thanks a lot to @RedShy for this change made in PR #477.
Signing & encrypting documents
FPDF.ink_annotation()has been introduced in v2.5.5 new to add path annotations: related documentation.
Documentation & translated tutorials
New translations of our tutorial were also provided:
What's coming next?
We have several enhancement proposals open (and mostly "up-for-grabs"),
and also an handful of good first issues dedicated to developpers would like to start contributing to
fpdf2 with a relatively easy task.
Among major projects, two contributors made very interesting & ambitious suggestions:
Finally, I am seriously considering to move the
fpdf2 project to the @py-pdf GitHub organization, in order to share ownership of several PDF-related Python libraries with other maintainers and join forces!
You can track this migration project and share your feedback in this GitHub discussion:
As always, I would be happy to receive your comments below 😊