diff --git a/label_printing/api.py b/label_printing/api.py index 071ebb0..53f25dd 100644 --- a/label_printing/api.py +++ b/label_printing/api.py @@ -41,9 +41,10 @@ def print_label(values): def print_label_by_server(doctype, name, qty, printer_setting, print_format=None, doc=None, no_letterhead=0, file_path=None): pdf_options = { - 'page-height': frappe.db.get_single_value('Label Printer Settings', 'label_height'), - 'page-width': frappe.db.get_single_value('Label Printer Settings', 'label_width'), + 'page-width': '{0}mm'.format(frappe.db.get_single_value('Label Printer Settings', 'label_width')), + 'page-height': '{0}mm'.format(frappe.db.get_single_value('Label Printer Settings', 'label_height')), } + print_settings = frappe.get_doc("Network Printer Settings", printer_setting) try: import cups @@ -56,8 +57,6 @@ def print_label_by_server(doctype, name, qty, printer_setting, print_format=None conn = cups.Connection() output = PdfFileWriter() output = frappe.get_print(doctype, name, print_format, doc=doc, no_letterhead=no_letterhead, as_pdf = True, output = output, pdf_options=pdf_options) - print("Here") - print(output) if not file_path: file_path = os.path.join("/", "tmp", "frappe-pdf-{0}.pdf".format(frappe.generate_hash())) output.write(open(file_path,"wb")) diff --git a/label_printing/label_printing/print_format/label/__init__.py b/label_printing/label_printing/print_format/label/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/label_printing/label_printing/print_format/label/label.json b/label_printing/label_printing/print_format/label/label.json new file mode 100644 index 0000000..6225eca --- /dev/null +++ b/label_printing/label_printing/print_format/label/label.json @@ -0,0 +1,25 @@ +{ + "absolute_value": 0, + "align_labels_right": 0, + "creation": "2022-03-01 09:42:22.551134", + "css": ".print-format { margin: 0; padding: 0; width: 104mm; max-height: 40mm; } .page-size { width: 104mm; } .label-wrapper { width: 100%; text-align: center; display: -webkit-box; /* wkhtmltopdf uses this one */ display: -webkit-flex; display: flex; -webkit-box-pack: center; /* wkhtmltopdf uses this one */ -webkit-justify-content: center; justify-content: center; font-size: 19px; } .left-wrapper { width: 80%; } .left-wrapper div { white-space: nowrap; font-size: 15px; } .right-wrapper { width: 20%; text-align: right; } .label-wrapper h4 { margin: 0; word-break: break-all; font-size: 25px; } .label-wrapper h4 small { color: black; } .barcode { font-family: 'Libre Barcode 128', cursive; font-size: 30px; }", + "custom_format": 1, + "disabled": 0, + "doc_type": "Label", + "docstatus": 0, + "doctype": "Print Format", + "font": "Default", + "html": "
\n\n
\n {% if doc.item_code %}\n

\n {{doc.item_code}}\n

\n {% endif %}\n\n {% if doc.item_name%}\n

\n {{doc.item_name}}\n

\n {% endif %}\n\n\n {% if doc.customer %}\n
{{doc.customer}}
\n {% endif %}\n\n {% if doc.delivery_date %}\n
\n {{_(\"Delivery Date\")}} {{frappe.utils.formatdate(doc.delivery_date, \"dd.MM.YYYY\")}}\n
\n {% endif %}\n\n {% if doc.batch %}\n
\n {{_(\"Batch\")}} {{doc.batch}}\n
\n {% endif %}\n\n {% if doc.qty %}\n
\n {{_(\"Qty\")}} {{ doc.qty }}\n
\n {% endif %}\n\n {% if doc.information%}\n
\n {{doc.information}}\n
\n {% endif %}\n\n\n
\n \n
\n \n
\n\n\n
", + "idx": 0, + "line_breaks": 0, + "modified": "2022-03-01 09:43:42.031856", + "modified_by": "christian@prothmann.com", + "module": "Label Printing", + "name": "Label", + "owner": "christian@prothmann.com", + "print_format_builder": 1, + "print_format_type": "Jinja", + "raw_printing": 0, + "show_section_headings": 0, + "standard": "Yes" +} \ No newline at end of file