top | item 41376362

What libraries are you using for PDF Generation?

4 points| ReedGraff | 1 year ago

I've used every single PDF library that you could possibly name in python and c++, and I haven't found a great solution for generating good looking pdfs. Would love to know what y'all are using.

Example: Generating an invoice. Generating a user-facing report.

I'm currently using reportlab, but am struggling with poor examples, And converting HTML to PDF has not been reliable.

3 comments

order
[+] zarekr|1 year ago|reply
There is no decent solution in Python and I’ve had the same experience with HTML as you, even using Weasyprint (which is the most popular solution for this). Instead I have been using typst (the rust based CLI). There is a Python library that provides bindings or you can run a subprocess to generate the files. It only takes a day or two to get to grips with the typst model and then you can write functions to produce consistent looking pdf files very quickly and with far less overhead than using headless chrome (ie. Playwright or puppeteer).
[+] eternityforest|1 year ago|reply
I never found any good way myself either, and wound up just writing HTML and manually opening in chrome and printing to file.

Unfortunately Chrome doesn't do booklet imposing that I can find, so if I ever need to programmatically make a booklet I have no idea what I'll do... Probably use one of those not-that-great tools or try to make an odt file and print from LibreOffice.