From 59bc47f7ade1a7c6fd4ad11310b837369143e009 Mon Sep 17 00:00:00 2001 From: Alaguraj0361 Date: Wed, 20 May 2026 12:53:24 +0530 Subject: [PATCH] remove product images from invoice PDF and adjust table layout columns --- pdfGenerator.js | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/pdfGenerator.js b/pdfGenerator.js index 3974d84..425d654 100644 --- a/pdfGenerator.js +++ b/pdfGenerator.js @@ -200,8 +200,7 @@ const generateInvoicePDF = async (orderData) => { .fillColor(primaryColor); doc.text('S.No', 40, tableY, { width: 35 }); - doc.text('Image', 85, tableY, { width: 60 }); - doc.text('Product', 155, tableY, { width: 200 }); + doc.text('Product', 85, tableY, { width: 270 }); doc.text('Quantity', 365, tableY, { width: 50, align: 'right' }); doc.text('Unit price', 425, tableY, { width: 60, align: 'right' }); doc.text('Total price', 495, tableY, { width: 60, align: 'right' }); @@ -223,14 +222,6 @@ const generateInvoicePDF = async (orderData) => { for (let i = 0; i < orderData.line_items.length; i++) { const item = orderData.line_items[i]; - // Fetch product image buffer - let imageBuffer = null; - if (item.image) { - imageBuffer = await fetchImageBuffer(item.image); - } else if (item.featured_image && item.featured_image.url) { - imageBuffer = await fetchImageBuffer(item.featured_image.url); - } - // Background color for alternating rows if (i % 2 === 1) { doc.rect(40, tableY - 4, 515, 38).fill(rowAltColor); @@ -243,24 +234,15 @@ const generateInvoicePDF = async (orderData) => { // S.No doc.text((i + 1).toString(), 40, tableY); - // Image - if (imageBuffer) { - try { - doc.image(imageBuffer, 85, tableY - 2, { fit: [35, 30] }); - } catch (err) { - console.error('Failed to draw item image:', err); - } - } - // Product Name and Variant/Quantity details const productText = item.title || item.name; - doc.text(productText, 155, tableY, { width: 200, height: 15, ellipsis: true }); + doc.text(productText, 85, tableY, { width: 270, height: 15, ellipsis: true }); // Display quantity/variant info if available if (item.variant_title) { doc.fontSize(8) .fillColor('#64748b') - .text(item.variant_title, 155, tableY + 12, { width: 200 }); + .text(item.variant_title, 85, tableY + 12, { width: 270 }); } // Reset font size