WeasyPrint v64 Has Been Released
WeasyPrint v64 has been released, it comes with eInvoices support, new text features, speed improvements and a lot of bug fixes! ❄️
eInvoices
Many users (maybe you?) use WeasyPrint to generate great PDF invoices. PDF invoices are an obvious way to avoid printed paper, and they are common today in a lot of companies. But PDFs are not perfect: they embed invoice information in a way that’s visually accessible to people, but not to computers. The PDF format is known to be hard to parse, and almost impossible to get data in a logically structured way. That’s why invoices have to be manually or semi-automatically inserted into accounting or bank software.
This manual step is repetitive, useless work that often leads to copy/paste errors. That’s why the European commission built a solution called eInvoices, the next generation of electronic invoices. eInvoices bring a lot of possibilities and simplifications, thanks to standard formats that can be use by different platforms: faster payments, automatic VAT declarations, easy classification of income and outcome… The goal is to help companies to reduce their administrative costs, and help countries to fight fraud.
The European commission proposed a standard, EN16931, that defines the structure and the transmission systems of eInvoices. But this structure is not a format, it’s a list of possible ways to structure invoice metadata using XML. So, different formats have been created to embed these metadata, including… PDF 📝.
France and Germany then developed two different formats called Factur-X and ZUGFeRD, both based on PDF and respecting the EN16931 standard. At the beginning, these formats were different, even if they shared most of the general structure: PDF documents with attached XML files.
Having two different but very close formats was for sure a bad situation. That’s why the teams behind the two formats worked to merge the formats into one single format. Since November 2024, Factur-X is the same standard as ZUGFeRD, based on the PDF/A standard, a PDF variant specialized on archiving. It is the first and one of the main implementations of EN16931.
WeasyPrint could already generate PDF/A document, that was a start. But what about embedding the XML metadata part?
Thanks to the hard work of Binary Butterfly 💜, a new API has been built to easily include Factur-X / ZUGFeRD metadata in WeasyPrint, and this new API is available in version 64.0! A simple example has also been added to the documentation, with many other new examples related to PDF features and metadata, to help users integrate WeasyPrint into their invoicing systems.
The only part that’s not covered by WeasyPrint is the generation of EN16931-compatible XML metadata. Of course, WeasyPrint can’t take the responsibility to handle this step itself, but we can rely on the Python community to provide open-source libraries for this step. Until then, it is possible to generate such XML files using your favorite XML generator.
If you’re interested in eInvoices generation, you can the new API of version 64.0 to see if it fits your needs! Don’t hesitate to contact us if you have questions or remarks, we’ll be happy to help you and help the community generate beautiful and valid Factur-X / ZUGFeRD invoices.
Text Features and Speed
Version 64 brings new features and speed improvements for text 🔥.
Text decoration got the new text-decoration-thickness
and
text-underline-offset
properties supported. If you want to
control the way your text is underlined, you have new toys to play with!
Small-caps synthesis has also been added. If you use a font that doesn’t contain specific small-caps characters, these characters will be automatically created for you, just as in other browsers.
This new version also includes tiny changes in the way text layout is done. They’re tiny, but they give impressive speed improvements in some cases:
- if your document contains a lot of text, with a lot of regular paragraphs, you can expect a 5% speed improvement for your overall document generation;
- if you render very, very long strings of plain text, split between multiple pages, then you can expect more: one of our tests is now 10 times faster!
What’s Next?
We hope you’ll have fun with this new version and that all these new features will be useful for you!
What’s next? Many things are coming as WeasyPrint has been selected by the NLnet Foundation to receive a NGI Zero Grant 🤩.
This grant allows us to book time to work on nice features and improvements for WeasyPrint like rewriting the flex layout, improving PDF/UA support and working on CMYK support.
If you’re interested in participating in WeasyPrint, opening issues and pull requests is a good way to start. If you want to dive into the code, a list of good first issues is waiting for you! Choose your favorite issue and write a short comment, we’ll be happy to help you!
And of course you can also become a sponsor on OpenCollective, it helps us to have more time to work on WeasyPrint and its dependencies.