numerus/pkg
jordi fita mas 4d2379555e Convert invoices to PDF with WeasyPrint
Although it is possible to just print the invoice from the browser, many
people will not even try an assume that they can not create a PDF for
the invoice.

I thought of using Groff or TeX to create the PDF, but it would mean
maintaining two templates in two different systems (HTML and whatever i
would use), and would probably look very different, because i do not
know Groff or TeX that well.

I wish there was a way to tell the browser to print to PDF, and it can
be done, but only with the Chrome Protocol to a server-side running
Chrome instance.   This works, but i would need a Chrome running as a
daemon.

I also wrote a Qt application that uses QWebEngine to print the PDF,
much like wkhtmltopdf, but with support for more recent HTML and CSS
standards.  Unfortunately, Qt 6.4’s embedded Chromium does not follow
break-page-inside as well as WeasyPrint does.

To use WeasyPrint, at first i wanted to reach the same URL as the user,
passing the cookie to WeasyPrint so that i can access the same invoice
as the user, something that can be done with wkhtmltopdf, but WeasyPrint
does not have such option.  I did it with a custom Python script, but
then i need to package and install that script, that is not that much
work, but using the Debian-provided script is even less work, and less
likely to drift when WeasyPrint changes API.

Also, it is unnecessary to do a network round-trip from Go to Python
back to Go, because i can already write the invoice HTML as is to
WeasyPrint’s stdin.
2023-02-26 17:26:09 +01:00
..
company.go Allow multiple taxes, and even not tax, for products 2023-02-08 13:47:36 +01:00
contacts.go Refactor checking for pgx.ErrNoRows in a function 2023-02-14 12:46:11 +01:00
db.go Properly register array and composite PostgreSQL types with pgtype 2023-02-20 11:42:21 +01:00
form.go Properly register array and composite PostgreSQL types with pgtype 2023-02-20 11:42:21 +01:00
invoices.go Convert invoices to PDF with WeasyPrint 2023-02-26 17:26:09 +01:00
locale.go Add currency_pattern to language relation 2023-02-23 12:12:33 +01:00
logger.go Move source file to the root of pkg 2023-01-17 10:40:22 +01:00
login.go Replace default router with github.com/julienschmidt/httprouter 2023-02-03 12:30:56 +01:00
pgtypes.go Temporarily switch to admin role to register types 2023-02-24 13:17:37 +01:00
products.go Use left join between products and taxes 2023-02-25 03:20:34 +01:00
profile.go Allow multiple taxes, and even not tax, for products 2023-02-08 13:47:36 +01:00
recover.go Gofmt recover.go 2023-01-22 20:37:34 +01:00
router.go Convert invoices to PDF with WeasyPrint 2023-02-26 17:26:09 +01:00
template.go Adjust invoice.css to work with WeasyPrint too 2023-02-25 03:16:20 +01:00