diff --git a/frappe/printing/page/print/print.js b/frappe/printing/page/print/print.js index 0e5d68c165..a46299a371 100644 --- a/frappe/printing/page/print/print.js +++ b/frappe/printing/page/print/print.js @@ -499,7 +499,16 @@ frappe.ui.form.PrintView = class { this.$print_format_body .find("body") .html(``); - + const iframeDoc = this.$print_format_body[0]; + const script = iframeDoc.createElement("script"); + script.src = "https://cdn.jsdelivr.net/npm/jsbarcode@3/dist/JsBarcode.all.min.js"; + script.onload = () => { + iframeDoc.querySelectorAll("svg[data-barcode-value]").forEach((el) => { + JsBarcode(el, el.dataset.barcodeValue, { width: 3, height: 50, fontSize: 16 }); + el.setAttribute("width", "100%"); + }); + }; + iframeDoc.head.appendChild(script); this.show_footer(); this.$print_format_body.find(".print-format").css({ diff --git a/frappe/templates/print_formats/standard_macros.html b/frappe/templates/print_formats/standard_macros.html index 4aeb657edf..1f4d2fab96 100644 --- a/frappe/templates/print_formats/standard_macros.html +++ b/frappe/templates/print_formats/standard_macros.html @@ -157,6 +157,9 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}" {% elif df.fieldtype=="Signature" %} + {% elif df.fieldtype=="Barcode" %} + + {% elif df.fieldtype in ("Attach", "Attach Image") and frappe.utils.is_image(doc[df.fieldname]) %} diff --git a/frappe/www/printview.html b/frappe/www/printview.html index 17e6380baa..f599388137 100644 --- a/frappe/www/printview.html +++ b/frappe/www/printview.html @@ -6,6 +6,41 @@ {{ title }} {{ include_style('print.bundle.css') }} + + {% if print_style %}