Hacker News new | ask | show | jobs
by perlgeek 615 days ago
In the near future, I'll have to program the document generation part of an invoicing system.

In the past, I've done generated PDF documents through latex, and didn't really like the process (for one, escaping is just so weird in latex, \ to \textbackslash for example).

I've thought about generating HTML and using a headless browser that can produce PDFs for me, but I don't know how well you can e.g. control page breaks with CSS these days.

Maybe typst is actually a good alternative here? Does anybody have experience with typst and multi-page tables?

4 comments

I think you're looking for Quarto. Quarto can also compile to Typst for typesetting, but you can get simultaneous HTML/PDF/Word outputs from a single markdown input.
I'm doing PDF document generation in typst, the format I'm generating is similar to invoices (specific to how the law in my country is, but that's a longer story).

Typst code generation was easy to automate with trivial python templates (jinja2). The core part of my document are multi-page tables, and typst splits them nicely.

I had to google around a bit, as there are multiple settings on how large tables are handled, I suggest that you give Typst a try, you can build a working prototype in no time

Thanks! Are you using the json loading feature in typst at all?
Nope, didnt event knew such a thing existed :)
I think css is fine at doing page breaks. https://developer.mozilla.org/en-US/docs/Web/CSS/break-befor...
I have been building tools for document generation out of templates using Typst for a few months. It works great!

So far, I haven't found any bigger issues with multi-page tables in Typst. For example, it was no big deal, to get subtotals in an invoice for every page break.