Added Title to Document Creation

Added Height Calc for Row Description
This commit is contained in:
2024-08-22 19:48:11 +02:00
parent a349b1eb4f
commit 7457abb173
2 changed files with 62 additions and 15 deletions

View File

@@ -593,7 +593,7 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
invoiceData.rows.forEach((row,index) => {
if(row.mode !== 'pagebreak'){
if(row.mode !== 'pagebreak' && row.mode !== 'title'){
pages[pageCounter - 1].drawText(String(row.pos), {
...getCoordinatesForPDFLib(21,rowHeight, page1),
@@ -625,7 +625,7 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
if(row.description) {
pages[pageCounter - 1].drawText(row.description, {
...getCoordinatesForPDFLib(52,rowHeight + 7, page1),
...getCoordinatesForPDFLib(52,rowHeight + 5, page1),
size:10,
color:rgb(0,0,0),
lineHeight:10,
@@ -667,10 +667,14 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
})
}
if(row.description) {
rowHeight += 24
let lineBreaks = (row.description.match(/\n/g) || []).length
let autoLines = (row.description.match(/.{1,50}/g) || []).length
rowHeight += 14 + (lineBreaks + autoLines) * 2.5
} else {
rowHeight += 14
rowHeight += 10
}
@@ -784,6 +788,29 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
} else if (row.mode === 'title') {
if(index === 0) {
rowHeight += 3
}
pages[pageCounter - 1].drawRectangle({
...getCoordinatesForPDFLib(20,rowHeight, page1),
width: 180 * 2.83,
height: 8 * 2.83,
color: rgb(0,0,0),
opacity: 0.25
})
pages[pageCounter - 1].drawText(row.text, {
...getCoordinatesForPDFLib(21,rowHeight -3, page1),
size:12,
color:rgb(0,0,0),
lineHeight:12,
opacity: 1,
maxWidth: 240,
font: fontBold
})
rowHeight += 8
}
@@ -797,7 +824,7 @@ export const useCreatePdf = async (invoiceData,backgroundSourceBuffer) => {
//Footer
console.log(rowHeight)
//console.log(rowHeight)
//rowHeight += 25
pages[pageCounter - 1].drawRectangle({
...getCoordinatesForPDFLib(20,rowHeight, page1),