Rendering Corrections

This commit is contained in:
2024-09-29 11:40:03 +02:00
parent f9995505a8
commit ffea7627cf

View File

@@ -593,7 +593,9 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
invoiceData.rows.forEach((row,index) => { invoiceData.rows.forEach((row,index) => {
if(row.mode !== 'pagebreak' && row.mode !== 'title'){
if(!["pagebreak","title","text"].includes(row.mode)){
console.log(row) console.log(row)
@@ -615,13 +617,14 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
maxWidth: 240 maxWidth: 240
}) })
console.log(row.text.match(/.{1,35}/g))
pages[pageCounter - 1].drawText(row.text.match(/.{1,35}/g).join("\n"), { pages[pageCounter - 1].drawText(row.text.match(/.{1,35}/g).join("\n"), {
...getCoordinatesForPDFLib(52,rowHeight, page1), ...getCoordinatesForPDFLib(52,rowHeight, page1),
size:10, size:10,
color:rgb(0,0,0), color:rgb(0,0,0),
lineHeight:10, lineHeight:10,
opacity: 1, opacity: 1,
maxWidth: 10,
font: fontBold font: fontBold
}) })
@@ -637,7 +640,6 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
color:rgb(0,0,0), color:rgb(0,0,0),
lineHeight:10, lineHeight:10,
opacity: 1, opacity: 1,
maxWidth: 220,
}) })
} }
@@ -679,9 +681,9 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
if(row.description) { if(row.description) {
let lineBreaks = (row.description.match(/\n/g) || []).length let lineBreaks = (row.description.match(/\n/g) || []).length
let autoLines = (row.description.match(/.{1,70}/g) || []).length let autoLines = (row.description.match(/.{1,70}/g) || []).length
rowHeight += 14 + (lineBreaks + autoLines + textAutoLines) * 2.5 rowHeight += 12 + (lineBreaks + autoLines + textAutoLines) * 2.5
} else { } else {
rowHeight += 10 rowHeight += 12 + textAutoLines * 2.5
} }
@@ -799,6 +801,18 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
if(index === 0 ||pageIndex === 0) { if(index === 0 ||pageIndex === 0) {
rowHeight += 3 rowHeight += 3
} }
pages[pageCounter - 1].drawText(String(row.pos), {
...getCoordinatesForPDFLib(21,rowHeight -3, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
maxWidth: 240,
font: fontBold
})
pages[pageCounter - 1].drawRectangle({ pages[pageCounter - 1].drawRectangle({
...getCoordinatesForPDFLib(20,rowHeight, page1), ...getCoordinatesForPDFLib(20,rowHeight, page1),
width: 180 * 2.83, width: 180 * 2.83,
@@ -808,7 +822,7 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
}) })
pages[pageCounter - 1].drawText(row.text, { pages[pageCounter - 1].drawText(row.text, {
...getCoordinatesForPDFLib(21,rowHeight -3, page1), ...getCoordinatesForPDFLib(35,rowHeight -3, page1),
size:12, size:12,
color:rgb(0,0,0), color:rgb(0,0,0),
lineHeight:12, lineHeight:12,
@@ -818,6 +832,48 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
}) })
rowHeight += 8 rowHeight += 8
} else if (row.mode === 'text') {
if(index === 0 ||pageIndex === 0) {
rowHeight += 3
}
let textAutoLines = (row.text.match(/.{1,70}/g) || []).length
pages[pageCounter - 1].drawRectangle({
...getCoordinatesForPDFLib(20,rowHeight, page1),
width: 180 * 2.83,
height: 8 * 3,
color: rgb(0,0,0),
opacity: 0.25
})
pages[pageCounter - 1].drawText(row.text.match(/.{1,70}/g).join("\n"), {
...getCoordinatesForPDFLib(21,rowHeight - 3, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
font: fontBold
})
//let textLineBreaks = (row.text.match(/\n/g) || []).length
//console.log(textAutoLines)
if(row.description) {
pages[pageCounter - 1].drawText(row.description.match(/.{1,85}/g).join("\n"), {
...getCoordinatesForPDFLib(21,rowHeight + ( textAutoLines * 4), page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
opacity: 1,
})
}
let addHeight = ((row.description.match(/.{1,85}/g) || []).length + textAutoLines) * 8
console.log(addHeight)
rowHeight += addHeight
} }