richeterre / jumubase

A friendly monolith for managing "Jugend musiziert" contests ♫
MIT License
3 stars 0 forks source link

Replace wkhtmltopdf by more robust PDF generator #11

Open richeterre opened 5 years ago

richeterre commented 5 years ago

wkhtmltopdf, which our elixir-pdf-generator dependency uses under the hood, is rather dated and based on an old version of Qt/WebKit that doesn't support Flexbox (see https://github.com/wkhtmltopdf/wkhtmltopdf/issues/1522).

Since Flexbox would make the layouting of our PDFs a lot easier, we should look out for alternative solutions with modern CSS support (or a different PDF generation approach altogether, which would have to support tables, though).

flyte commented 5 years ago

I've just replaced wkhtmltopdf with headless chromium, controlled by puppeteer (actually pyppeteer, the python version). https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions

Thought that might help!

richeterre commented 5 years ago

Thank you for the suggestion! I found this, but it requires passing a URL to render to PDF: https://github.com/hassox/hpdf

Might still work if I add routes for HTML rendering and print stylesheets to my printable pages, and pass that path to the PDF generator. Then I could probably debug everything easily using Chromium.

richeterre commented 2 years ago

Note to self: Check out https://hex.pm/packages/pdf