Hacker News new | ask | show | jobs
by Crowberry 831 days ago
I'm with you..

We ended up writing a similar wrapper around https://github.com/jung-kurt/gofpdf library. We haven't open sourced it yet. But it's made it a lot easier to deal with rendering a PDF, especially over pagebreaks ect.

2 comments

A while ago I created a pdf report generation engine for Python, supporting Jinja2 template syntax, and server and client-side generation of content. Page formatting is handled by https://pagedjs.org/, and PDF generation is performed via a separate api daemon based on chrome-headless: https://zipreport.github.io/zipreport/ It is not fast, but it works quite well.
Yes, page breaks are probably the most significant difference between the layout of a web page and a PDF document, and thereby a major drawback when using HTML-to-PDF. There is little to no tooling for this in the web.

If you want granular control over how your PDF will look with content that is more than one page long, you will have a hard time using html.

We actually provide helpers to do that in our React library https://react.onedoclabs.com/components/shell#pagebreak

CSS actually implements the break-before property to control this https://developer.mozilla.org/en-US/docs/Web/CSS/break-befor... which is also supported by the Print to PDF dialog in modern browsers.

That's what we are trying to solve at Onedoc, we want developers to be able to have full control over the PDF layout as they write content. react-print is built with the intention of creating the illusion that React was meant for PDFs.