fpdf2 is a minimalist PDF creation library for Python that I am maintaining.
With the release yesterday of its
v2.4.0, I'm going to present some of its notable new features since the latest minor version.
JPEG images take less space
fpdf2 now uses the newly supported
DCTDecode image filter for JPEG images, in order to improve the compression ratio without any image quality loss.
On test images, this reduced the size of embedded JPEG images by 90%.
Basic Markdown styling
fpdf2 now allows to use basic Markdown-like styling:
**bold**, __italics__, --underlined--.
Currently, this is only supported by the
markdown=True, but I plan to also implement this for the
Document outline & table of contents
Quoting the PDF format reference:
A PDF document may optionally display a document outline on the screen, allowing the user to navigate interactively from one part of the document to another. The outline consists of a tree-structured hierarchy of outline items, which serve as a visual table of contents to display the document’s structure to the user.
v2.3.3 you can define such outlines, as well as tables of contents !
Full documentation: fpdf2 / Document outline & table of contents
fpdf2 now allows to add various PDF annotations, such as text annotations
or links to directly open other PDF files on the same file-system.
Full documentation: fpdf2 / Annotations
v2.3.1 alternative text descriptions can now be added by the
They allow screen readers to extract readable descriptions from images & links in the generated PDFs.
In PDF readers, presentation mode can usually be enabled with the
CTRL + L shortcut.
This release introduces support for page transitions in presentation mode:
now accepts two new optional parameters,
to define how the viewer application should advances to the next page.
Full documentation: fpdf2 / Presentations
After introducing this feature, I realized that PDF page durations allowed to build presentations that behave like GIFs: sequences of images, one per page, that move forward automatically.
Hence I wrote a little script,
to test this silly idea.
There are the result:
You can open those files in Adobe Acrobat Reader (page durations are ignored by some other PDF readers),
CTRL+L to launch presentation mode,
and then ENTER to admire the animation!
Of course PDF readers are not optimized for this kind of animated files, so the animation may be pretty slow, despite being configured to execute at 25 frames per second.
That's it for the notable recent features of
You can also check the detailed CHANGELOG
for an exhaustive list of all changes: bug fixes, other minor improvements and deprecation notices.
As someone recently asked about it: if ever you want to support my work on this open-source Python library, you can buy one of the games I published on itch.io.
Now I wish you to have a lot of fun building PDFs with
I recently used it myself to create an animated poem for my girlfriend 😉 I'd love to know what creations you have made using it, so please add comment below if you want to share them!