Hacker News new | ask | show | jobs
by malloc-0x90 874 days ago
I tried to use it to make an invoice system: wanted to convert plain-text CSV (description,amount,cost) --> to Markdown tables --> to PDF.

But I was unable to align the following 2nd table with taxes: cells are all over the place and it does whatever it wants. And there is no information online to be found about it.

(I eventually gave up long time ago and still to this day manually do them in LibreOffice Writer adding taxes with a calculator)

Except this, it's a really neat piece of FOSS software!

5 comments

Have you looked at hledger, which generates everything from plain-text accounts files?

https://hledger.org/

https://hledger.org/invoicing.html

https://plaintextaccounting.org/

One previous discussion: https://news.ycombinator.com/item?id=20012499

Maybe you could use html as an intermediate point instead of markdown. Might give you more control over the layout.

Might have to use a headless chromium wrapper (maybe pandoc has this anyway) to then get to pdf but that may not be too bad

I was thinking the same thing: I would use HTML as an intermediate, targeting PDF through weasyprint.

In fact I quite often go .md -> .html with pandoc, but write the .md in such a way that, when translated, it is the kind of html that weasyprint will be able to turn into the PDF that I want.

I tried something like that but ended up going with markdown -> html -> puppeteer to generate an A4 pdf -> ghostscript to compress it.

It’s an ugly script that’s been working quite well for more than a decade, but I wouldn’t recommend it to anyone other than myself.

I have a very similar homegrown mess. I wonder how many of us there are doing the same thing for this use case.
By looking at this thread, quite a few. The problem is creating a solution that would fit all of our idiosyncrasies.

For example, in my code, if a table has the class “total” it sums all <td>s which contains a dollar sign, and so on.

I use pandoc quite often - but I wish the intermediate, internal pandoc format was a little more expressive, exactly for things like this. I also tried making an invoice.
I just recently put together something for invoices that wound up being Jinja2 + data -> HTML-> weasyprint -> pdf. Was quite straight forward, all in all.