From 93a2d96c21039696b138e265988fbac08d35444a Mon Sep 17 00:00:00 2001 From: flfeders Date: Thu, 19 Sep 2024 19:34:41 +0200 Subject: [PATCH] Minor Changes in Invoice Creation --- composables/usePDFGenerator.js | 19 +++++++++++++------ pages/createDocument/edit/[[id]].vue | 19 ++++++++++++------- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/composables/usePDFGenerator.js b/composables/usePDFGenerator.js index 96ccc90..52e6166 100644 --- a/composables/usePDFGenerator.js +++ b/composables/usePDFGenerator.js @@ -595,6 +595,8 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => { if(row.mode !== 'pagebreak' && row.mode !== 'title'){ + console.log(row) + pages[pageCounter - 1].drawText(String(row.pos), { ...getCoordinatesForPDFLib(21,rowHeight, page1), size:10, @@ -613,19 +615,24 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => { maxWidth: 240 }) - pages[pageCounter - 1].drawText(row.text, { + pages[pageCounter - 1].drawText(row.text.match(/.{1,35}/g).join("\n"), { ...getCoordinatesForPDFLib(52,rowHeight, page1), size:10, color:rgb(0,0,0), lineHeight:10, opacity: 1, - maxWidth: 240, + maxWidth: 10, font: fontBold }) + //let textLineBreaks = (row.text.match(/\n/g) || []).length + let textAutoLines = (row.text.match(/.{1,35}/g) || []).length + console.log(textAutoLines) + + if(row.description) { - pages[pageCounter - 1].drawText(row.description, { - ...getCoordinatesForPDFLib(52,rowHeight + 5, page1), + pages[pageCounter - 1].drawText(row.description.match(/.{1,70}/g).join("\n"), { + ...getCoordinatesForPDFLib(52,rowHeight + ( textAutoLines * 4), page1), size:10, color:rgb(0,0,0), lineHeight:10, @@ -671,8 +678,8 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => { if(row.description) { let lineBreaks = (row.description.match(/\n/g) || []).length - let autoLines = (row.description.match(/.{1,50}/g) || []).length - rowHeight += 14 + (lineBreaks + autoLines) * 2.5 + let autoLines = (row.description.match(/.{1,70}/g) || []).length + rowHeight += 14 + (lineBreaks + autoLines + textAutoLines) * 2.5 } else { rowHeight += 10 } diff --git a/pages/createDocument/edit/[[id]].vue b/pages/createDocument/edit/[[id]].vue index ddcd5cd..57597ec 100644 --- a/pages/createDocument/edit/[[id]].vue +++ b/pages/createDocument/edit/[[id]].vue @@ -207,7 +207,8 @@ const addPosition = (mode) => { quantity: 1, price: 0, taxPercent: 19, - discountPercent: 0 + discountPercent: 0, + unit: 1 }) } else if(mode === 'service'){ itemInfo.value.rows.push({ @@ -216,7 +217,8 @@ const addPosition = (mode) => { quantity: 1, price: 0, taxPercent: 19, - discountPercent: 0 + discountPercent: 0, + unit: 1 }) } else if(mode === "pagebreak") { itemInfo.value.rows.push({ @@ -515,7 +517,7 @@ setupPage()
-
+
@@ -708,7 +710,7 @@ setupPage()
-
+
@@ -977,7 +979,6 @@ setupPage() > @@ -986,7 +987,9 @@ setupPage() v-else-if="row.mode === 'normal'" >