Print format in version-13

Hi all,

After upgrade to version-13 from version-12.
I found that jsbarcode is not showing on printview, only work in full page view.
also document.getElementById is also not working in 13, returning null.
I have try using script defer to wait for doc ready, but the result still null.

Its working in version-12.
Is this true ?

Thanks
Aditya

Hi,

There is a solution Ive found in the forum using barcode.tec-it
But library relying on window.document.getElement (like jsbarcode, qrcode etc._) will not work on the ‘app/print’ and only show
in the full page print view.

Anybody have work around for this.?

thanks and regards,
Aditya

Print format problems are commonly associated to a mismatched version of wkhtmltopdf (should be v0.12.6+ with qt patch)

where to find / how to upgrade wkhtmltopdf v0.12.5 to v0.12.6 with qt patch

thanks

Assuming you’re on debian 10+ or ubuntu 20+…

wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb && sudo dpkg --install wkhtmltox_0.12.6-1.focal_amd64.deb;
wkhtmltopdf --version  #Test the install: wkhtmltopdf 0.12.6 (with patched qt)

Hi,
I have installed wkhtmltopdf versin 0.12.6 and confirmed it
wkhtmltopdf --version
wkhtmltopdf 0.12.6 (with patched qt)

The problem is not fixed.
My print format was working perfectly in version-12 and break in version-13.
Barcode image not shown on the ‘app/print’ and only show (perfectly) in the full page print view

Although I can still use it and the print out still accessible by using full page view but I am not confidence to show it to my client.
I think I will pending the upgrade and keep version-12 while finding for solution.
I will also install another site on this version-13 bench and try again without my custom apps installed.
Maybe also try without erpnext/frappe only if the error is still the same.

thanks,
Aditya

You can try adding an entry to your hosts file, and then also put your domain into the site_config file.

from this post…Wkhtmltopdf layout error - #4 by lasalesi maybe check for

  • the hostname configuration of ERPNext (see site/site1.local/site_config.json should contain "host_name": "https://www.yourdomain.com",)

I have follow your suggestion but still got same error.
my site name is local.site

wkhtmltopdf 0.12.6 (with patched qt)

/etc/host edited, I can ping to local.site
sites/local.site/site_config.json added:

“host_name”: “http://local.site”,
“http_port” : 8004,

I have try print format on Frappe only site.
Here is the browser console error:

Unable to handle success response

  1. {message: {…}}

request.js:273 NoElementException: No element to render on. at new e (https://cdn.jsdelivr.net/npm/jsbarcode@latest/dist/JsBarcode.all.min.js?_=1684237442592:2:18330) at d.render (https://cdn.jsdelivr.net/npm/jsbarcode@latest/dist/JsBarcode.all.min.js?_=1684237442592:2:20627) at h (https://cdn.jsdelivr.net/npm/jsbarcode@latest/dist/JsBarcode.all.min.js?_=1684237442592:2:19000) at eval (eval at globalEval (http://local.site:8004/assets/frappe/js/lib/jquery/jquery.min.js:2:2640), :1:1) at eval () at Function.globalEval (http://local.site:8004/assets/frappe/js/lib/jquery/jquery.min.js:2:2640) at ua (http://local.site:8004/assets/frappe/js/lib/jquery/jquery.min.js:3:13257) at n.fn.init.append (http://local.site:8004/assets/frappe/js/lib/jquery/jquery.min.js:3:14539) at n.fn.init. (http://local.site:8004/assets/frappe/js/lib/jquery/jquery.min.js:3:15641) at K (http://local.site:8004/assets/frappe/js/lib/jquery/jquery.min.js:2:30342)

(anonymous) @ request.js:273
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
z @ jquery.min.js:4
(anonymous) @ jquery.min.js:4
load (async)
send @ jquery.min.js:4
ajax @ jquery.min.js:4
frappe.request.call @ request.js:251
frappe.call @ request.js:103
get_print_html @ print.js:623
preview @ print.js:396
refresh_print_format @ print.js:290
change @ print.js:101
(anonymous) @ base_control.js:181
handleMouseUp_ @ unknown
Promise.then (async)
(anonymous) @ dom.js:258
frappe.run_serially @ dom.js:256
set @ base_control.js:172
validate_and_set_in_model @ base_control.js:196
parse_validate_and_set_in_model @ base_control.js:158
change_handler @ data.js:142
dispatch @ jquery.min.js:3
r.handle @ jquery.min.js:3
handleMouseUp_ @ unknown

Sorry I forgot to mention it before but this error remain the same on these three sites,
barcode only shown on full preview ( also no related error on the browser console)

apps installed on site:

frappe, erpnext, myapp
frappe, erpnext
frappe

Is this means the error came from frappe ?

btw this is the format, its from jsbarcode sample:

pls note that with erpnext installed I dont do the import for jsbarcode.all.min.js since its already included.

Thanks
Aditya

Hi,

I found a way to do it on version 13 and 14. which are using jinja hook
The barcode / qrcode is printed both on app/print and full preview and pdf also.
Dont need to save the image on tables, just generate the barcode in external python module access
via hook.py setup , we need to install python library for barcode/qrcode and mention in custom-app/requirements.txt and do bench install requirements.

hooks.py

version 13:
jenv = {

}

version-14:
jinja = {
“methods”: [
“custom_app.directory.file.method”,
]
}

Thanks and regards,
Aditya

1 Like