Fixed label height issue

This commit is contained in:
CAnetzberger
2022-03-03 12:11:17 +01:00
parent 0a8cb76ad1
commit 6303177d00
3 changed files with 28 additions and 4 deletions

View File

@@ -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): def print_label_by_server(doctype, name, qty, printer_setting, print_format=None, doc=None, no_letterhead=0, file_path=None):
pdf_options = { pdf_options = {
'page-height': frappe.db.get_single_value('Label Printer Settings', 'label_height'), 'page-width': '{0}mm'.format(frappe.db.get_single_value('Label Printer Settings', 'label_width')),
'page-width': 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) print_settings = frappe.get_doc("Network Printer Settings", printer_setting)
try: try:
import cups import cups
@@ -56,8 +57,6 @@ def print_label_by_server(doctype, name, qty, printer_setting, print_format=None
conn = cups.Connection() conn = cups.Connection()
output = PdfFileWriter() 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) 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: if not file_path:
file_path = os.path.join("/", "tmp", "frappe-pdf-{0}.pdf".format(frappe.generate_hash())) file_path = os.path.join("/", "tmp", "frappe-pdf-{0}.pdf".format(frappe.generate_hash()))
output.write(open(file_path,"wb")) output.write(open(file_path,"wb"))

View File

@@ -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": "<div class=\"label-wrapper\">\n\n <div class=\"left-wrapper\">\n {% if doc.item_code %}\n <h4>\n <strong>{{doc.item_code}}</strong>\n </h4>\n {% endif %}\n\n {% if doc.item_name%}\n <h4>\n <small> {{doc.item_name}}</small>\n </h4>\n {% endif %}\n\n\n {% if doc.customer %}\n <div>{{doc.customer}}</div>\n {% endif %}\n\n {% if doc.delivery_date %}\n <div>\n <strong> {{_(\"Delivery Date\")}} </strong> {{frappe.utils.formatdate(doc.delivery_date, \"dd.MM.YYYY\")}}\n </div>\n {% endif %}\n\n {% if doc.batch %}\n <div>\n <strong>{{_(\"Batch\")}} </strong> {{doc.batch}}\n </div>\n {% endif %}\n\n {% if doc.qty %}\n <div>\n <strong>{{_(\"Qty\")}} </strong> {{ doc.qty }}\n </div>\n {% endif %}\n\n {% if doc.information%}\n <div>\n {{doc.information}}\n </div>\n {% endif %}\n\n\n </div>\n \n <div class=\"right-wrapper\">\n <img src=\"/files/hp_logo_black.jpg\" style=\"width: 50%;\">\n </div>\n\n\n</div>",
"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"
}