Hi all,
today I tried using the new weasyprint endpoint (/api/method/frappe.utils.weasyprint.download_pdf
), which worked perfectly, but only in older print formats. More recently created print formats gave me this error:
I looked at the Frappe source and my DB and noticed that newer print formats (I recently upgraded to ERPNext/Frappe 15, but even those created in 14 have this) have a JSON array instead of an object in the format_data
column:
The code seems able to only deal with objects, not the array-based format. What is the cause of this and how do I fix it? At first glance it looks like the code is out of date but I find that hard to believe…
Hi, how did you switch from wkhtmltopdf to weasyprint?
You have to enter this endpoint uri with the doctype, the print format and the document name like so:
https://avant-iconic.frappe.cloud/api/method/frappe.utils.weasyprint.download_pdf?doctype=Sales%20Invoice&name=SAMPLE-1337&print_format=AVANT%20ICONIC%20Deutschland
This is a generic Frappe thing, but should probably be explicitly documented somewhere, since Weasyprint is quite an improvement over wkhtmltopdf (when it works). Also I am not sure if there are ways to get this to work directly from the standard UI, I have not found one in the source.
I just created a github issue about this, let’s see if we get more info.
Long story short, weasyprint only works with either the Beta Print Format Builder, or the Print Designer, and might get superseded by a Chrome-based PDF generator (feat: Chrome PDF Generator by maharshivpatel · Pull Request #399 · frappe/print_designer · GitHub) that looks like it supports the old Print Format Builder and the Print Designer, but not the Beta Print Format Builder, which will likely be removed. It also looks like weasyprint support may get deprecated at some point.
For me personally, I am going to use the old Print Format Builder from now on and switch to the Chrom e PDF generator once that is ready. It’s unfortunate, but I know that Chrome will definitely do what i want css-wise.
1 Like