WeasyPrint

Bring the web to PDF and paper

Kozea

Industrialization example: 2000 customized pharmacy websites on the same code base.
e-learning: stylesheets rather than PowerPoint-style slides.
Reporting through CSS and SVG, including vector graphs of data aggregated on the fly, producing PDF.

Open-source

We use lower-level open-source bricks a lot.
You may have had a similar experience: you just use it, then start reporting issues, start looking at the code, start fixing issues yourself and send pull requests …

Making open-source

community.kozea.org

And at some point you may start your own open-source project. Find ours at community.kozea.org and on GitHub.

PDF

Flexible web documents are great but sometimes you need PDF. We want to generate them automatically as much as possible.

LaTeX → PDF

Painful, in one word.

SVG → PDF

More pleasant but hack-ish.

CairoSVG

By the way, we made our own SVG implementation in Python.

HTML+CSS → PDF

This is what we really want. It makes sense however we think of it.

CSS for Paged Media

h1 { page-break-before: right }
h1, h2, h3 {
    page-break-after: avoid }
@page { size: A4 landscape;
        margin: 2cm }
@page :left { @bottom-right {
    content: counter(page) } }
@media print { nav { display: none } }
    
Actually, CSS does have a lot for Paged Media: page break control, page sizing, headers and footers, …

HTML+CSS → PDF

… but Gecko and Webkit do not really implement these parts of CSS.
Specialized engines do, but didn’t fit for various reasons.

WeasyPrint

I said “No, it’s a bad I idea, we’re not gonna do that.” But we still did.
We’ve now been using WeasyPrint in production in multiple applications for 8+ months.
There are regular stable releases, you can use it.

W3C, CSS Working Group

Getting involved is a gradual process, even small contributions (like feedback on specs) are greatly appreciated.
But still, here I am today although one year ago I didn’t even consider this could ever happen!
My point is: you can do this too, at whatever scale you like.

CSS box model…

It’s complicated.

The CSS 2.1 spec has some “dark corners”… but don’t worry about those, we figured them out for you :)
There is plenty more that is easier to approach.

Thank you.

Come and chat with us!