updated to print labels
This commit is contained in:
@@ -126,12 +126,18 @@ class LabelPDFGenerator:
|
||||
canvas.drawString(q_x_centered, row_y + self.row_height/3, quantity)
|
||||
current_y = row_y
|
||||
|
||||
# Row 4: Customer order
|
||||
# Row 4: Customer order - CORRECTED to match HTML preview
|
||||
row_y = current_y - self.row_height
|
||||
canvas.setFont("Helvetica", 8)
|
||||
canvas.drawString(self.content_x + mm_to_points(2), row_y + self.row_height/3, "Customer order")
|
||||
canvas.setFont("Helvetica-Bold", 10)
|
||||
customer_order = str(order_data.get('com_achiz_client', 'N/A'))[:15]
|
||||
# Match HTML: com_achiz_client + "-" + nr_linie_com_client
|
||||
com_achiz_client = str(order_data.get('com_achiz_client', ''))
|
||||
nr_linie = str(order_data.get('nr_linie_com_client', ''))
|
||||
if com_achiz_client and nr_linie:
|
||||
customer_order = f"{com_achiz_client}-{nr_linie}"[:18]
|
||||
else:
|
||||
customer_order = "N/A"
|
||||
co_text_width = canvas.stringWidth(customer_order, "Helvetica-Bold", 10)
|
||||
co_x_centered = vertical_x + (self.right_column_width - co_text_width) / 2
|
||||
canvas.drawString(co_x_centered, row_y + self.row_height/3, customer_order)
|
||||
@@ -201,24 +207,26 @@ class LabelPDFGenerator:
|
||||
canvas.drawString(s_x_centered, row_y + self.row_height/3, size)
|
||||
current_y = row_y
|
||||
|
||||
# Row 8: Article Code
|
||||
# Row 8: Article Code - CORRECTED to use customer_article_number like HTML preview
|
||||
row_y = current_y - self.row_height
|
||||
canvas.setFont("Helvetica", 8)
|
||||
canvas.drawString(self.content_x + mm_to_points(2), row_y + self.row_height/3, "Article Code")
|
||||
canvas.setFont("Helvetica-Bold", 10)
|
||||
article_code = str(order_data.get('cod_articol', 'N/A'))[:12]
|
||||
# Match HTML: uses customer_article_number, not cod_articol
|
||||
article_code = str(order_data.get('customer_article_number', 'N/A'))[:12]
|
||||
ac_text_width = canvas.stringWidth(article_code, "Helvetica-Bold", 10)
|
||||
ac_x_centered = vertical_x + (self.right_column_width - ac_text_width) / 2
|
||||
canvas.drawString(ac_x_centered, row_y + self.row_height/3, article_code)
|
||||
current_y = row_y
|
||||
|
||||
# Row 9: Prod Order (but we'll show sequential number instead)
|
||||
# Row 9: Prod Order - CORRECTED to match HTML preview with sequential numbering
|
||||
row_y = current_y - self.row_height
|
||||
canvas.setFont("Helvetica", 8)
|
||||
canvas.drawString(self.content_x + mm_to_points(2), row_y + self.row_height/3, "Prod Order")
|
||||
canvas.setFont("Helvetica-Bold", 10)
|
||||
# Show original production order
|
||||
prod_order = str(order_data.get('comanda_productie', 'N/A'))
|
||||
# Match HTML: comanda_productie + "-" + sequential number (not quantity!)
|
||||
comanda_productie = str(order_data.get('comanda_productie', 'N/A'))
|
||||
prod_order = f"{comanda_productie}-{current_num:03d}" # Sequential number for this specific label
|
||||
po_text_width = canvas.stringWidth(prod_order, "Helvetica-Bold", 10)
|
||||
po_x_centered = vertical_x + (self.right_column_width - po_text_width) / 2
|
||||
canvas.drawString(po_x_centered, row_y + self.row_height/3, prod_order)
|
||||
@@ -232,7 +240,7 @@ class LabelPDFGenerator:
|
||||
|
||||
# Bottom horizontal barcode - positioned within label bounds
|
||||
barcode_area_height = mm_to_points(12) # Reserve space for barcode
|
||||
barcode_y = mm_to_points(5) # 5mm from bottom of label
|
||||
barcode_y = mm_to_points(3) # 3mm from bottom of label (moved down 1mm for more space)
|
||||
barcode_width = self.content_width # Use full content width
|
||||
barcode_x = self.content_x
|
||||
|
||||
@@ -269,8 +277,14 @@ class LabelPDFGenerator:
|
||||
vertical_barcode_width = mm_to_points(12) # Increased width for better fill
|
||||
|
||||
try:
|
||||
# Create vertical barcode code
|
||||
vertical_code = f"{current_num:03d}-{total_qty:02d}"
|
||||
# Create vertical barcode code - CORRECTED to match HTML preview
|
||||
# Use same format as customer order: com_achiz_client + "-" + nr_linie_com_client
|
||||
com_achiz_client = str(order_data.get('com_achiz_client', ''))
|
||||
nr_linie = str(order_data.get('nr_linie_com_client', ''))
|
||||
if com_achiz_client and nr_linie:
|
||||
vertical_code = f"{com_achiz_client}-{nr_linie}"
|
||||
else:
|
||||
vertical_code = "000000-00"
|
||||
|
||||
# Create a vertical barcode using Code128
|
||||
v_barcode = code128.Code128(vertical_code,
|
||||
|
||||
Reference in New Issue
Block a user