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.
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.
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.
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.
Going all the way down to raw HTML is a bit verbose, but with almost anything I've thrown at it - CV's, business cards, you name it - it hasn't let me down yet.
I think you can pay for more complicated services, but I didn't need to go that far. It was more about generating a PDF from HTML without manually invoking File > Save as PDF each time.
Tl;dr I'm lazy ¯\_(ツ)_/¯
Installed w/ Homebrew, it's really nothing more than running `weasyprint input.html output.pdf`
https://doc.courtbouillon.org/weasyprint/stable/first_steps....
1. HTML-to-PDF: The web has a great layout system that works well for dynamic content. So using that seems like a good idea. BUT it is not very efficient as a lot of these libraries simply spin up a headless browser or deal with virtual doms.
2. PDF Libraries (like jsPDF): They mostly just have methods like ".text(x, y, string) which is an absolute pain to work with when building dynamic content or creating complex layouts.
This was such a pain point in various projects I worked on that I built my own library that has a component system to build dynamic layouts (like tables over multiple pages) and then computes that down to simple jsPDF commands. Giving you the best of both worlds.
Hope this makes somebody's life a bit easier: https://github.com/DevLeoko/painless-pdf