I am working on a HTML-to-PDF converter written from scratch in pure Go. I got tired of using headless browsers for various reasons and decided to give it a try and implement something that I can use internally. However the results have far exceed my expectations and I've decided to open source everything. It's around 10x to 15x faster than wkhtmltopdf, which is by far the fastest headless browser converter. It's 80x-100x faster than a pagedjs. It's even 2x faster than PrinceXML, which is pretty much the most mature and reliable HTML-to-PDF converter on the market. It also produces the smallest PDF size.
I started small as a toy project, but gradually implemented full support for proper block context, flexbox layout, CSS variables, tables, etc. to the point where I have almost full support of all major CSS features (even math functions like calc(), min(), max()).
I'm cleaning up the code right now and will upload it later today or maybe tomorrow here: https://github.com/PureGoPDF
Do you intend to one day support all the paged media bits in pagedjs? I assume it works with their polyfill but it’d be great to have a built in more performant option.
Can you give an example? I'm not that familiar with pagedjs, just pulled it for the benchmark.
My library has support for @page rules, but that's actually pretty basic. I needed more advanced headers/footers and added support for in-html headers/footers like this: In your <body> you cna define headers/footers by wrapping content in a <section> tag. For example:
<body> <section> <header>... any HTML here, full CSS support</header>
</body>This structure is purely optional, but it's a really convinient way of designing pages with different styles in the same document. An HTML file can have any number of these sections meaning you can generate a PDF with different headers/footers.
Some other bits: It has support for 100% height that match the entire page, it can handle forced page breaks inside flexbox containers (Chrome doesn't even try ... just ignores it) and also follows page-break: avoid correctly - so it doesn't randomly split table rows for example.
> PureGoPDF doesn't have any public repositories yet.
> I'm cleaning up the code right now and will upload it later today or maybe tomorrow here