4 ms·
We use wkhtmltopdf to do this server side. It as a few problems and quirks, but it work well enough for us.
by mchiron 9y ago
We use wkhtmltopdf to do this server side. It as a few problems and quirks, but it work well enough for us.
- pilif 9y agoit has a lot of quirks, and, frankly, webkit is pretty bad at printing in general as it lacks a ton of printing specific features like re-printing table headers across page boundaries. There's also only very rudimentary support for page headers and footers. wkhtmktopdf is probably ok if you just need a quick single page invoice printout, but the moment you need more (in our case, we definitely do), I can highly recommend paying for https://www.princexml.com/ https://www.princexml.com/ which has support for a lot of printing specific features.
- veza 9y agowkhtmltopdf works quite well for us, even with modern web technologies. Here's an example fully rendered in React: https://s3.amazonaws.com/ud-reports/comps-report-86.pdf https://s3.amazonaws.com/ud-reports/comps-report-86.pdf And one with svg charts: https://s3.amazonaws.com/ud-reports/chart-report-89.pdf https://s3.amazonaws.com/ud-reports/chart-report-89.pdf With -webkit- prefixes you can use even flexbox, and and with js polyfills you'll have all you need. Of course if I would start a project now, I would use chrome headless, but I don't feel wkhtmltopdf is that bad.
- bowersbros 9y agoOne of the issues we had with wkhtmltopdf was that we use Angular for our views, and we have a view for an invoice, and the ability to print it. We wanted the same view to be passed into wkhtmltopdf to download it as PDF (with a couple of things omitted). Unfortunately, the JS didn't execute properly, so you get a borked output. End result was we render it, capture the HTML after render, and pipe that through to wkhtmltopdf. Using chrome _should_ resolve that issue and let us just pass the page through.