natancabral / pdfkit-table

Helps to draw informations in simple tables using pdfkit. #server-side. Generate pdf tables with javascript (PDFKIT plugin)
MIT License
93 stars 59 forks source link

Overlapping tables #60

Open YoelEigner opened 1 year ago

YoelEigner commented 1 year ago

I'm having some issues with overlapping tbales, I saw some other folks having similar issues but this seems different and the fixes in those posts don't work.

Screenshot 2023-01-08 180957

The applied Payments Total should be after the applied payments table not on top. I did add if (doc.y > 0.8 * doc.page.height) { doc.addPage() } each time before i create a new table to make sure they don't overlap but in a few instances they still do

This is my table creation if (doc.y > 0.8 * doc.page.height) { doc.addPage() } showappliedPaymentsTotalTable && await doc.table(totalAppliedPaymentsTable, { prepareHeader: () => doc.font("Helvetica-Bold").fontSize(8), prepareRow: (row, indexColumn, indexRow, rectRow, rectCell) => { virticalLines(doc, rectCell, indexColumn) indexColumn === 4 && doc.addBackground(rectCell, 'red', 0.15); doc.font("Helvetica").fontSize(8); }, });

and this is this the table that is making issues

title: "Applied Payments Total", subtitle: "From " + date.start + " To " + date.end, headers: [ { label: "Client Payments", renderer: null, align: "center" }, { label: "Client Hours", renderer: null, align: "center" }, { label: "Payments From Supervisee's clients", renderer: null, align: "center" }, { label: "Hours From Supervisee's clients", renderer: null, align: "center" }, { label: "Adjustment Fees", renderer: null, align: "center" }, { label: "Total Applied Payments", renderer: null, align: "center" } ], rows: [[ formatter.format(clientPayments), clientHours.toFixed(0), formatter.format((superviseeClientsPayment - totalAppliedAmount) + totalSupPracAmount), superviseeClientsHours.toFixed(0), formatter.format(ajustmentFeesTotal), formatter.format(total), ]],

marloweoliver commented 1 year ago

I am having the same issue, unfortunately. Did you ever find a solution?

YoelEigner commented 1 year ago

No. Im still having this issue, it doesn't happen often but it happens 🥲

YoelEigner commented 11 months ago

@callihann dis you find a solution? I keep running into this and i need a fix urgently

marloweoliver commented 11 months ago

Hey @YoelEigner, I was never able to find a definite fix. However, I used a workaround that detected the height of the page and added a new page if necessary. This fix is fairly rudimentary but worked for my use case.

if (doc.y > 0.8 * doc.page.height) {
        doc.addPage();
}
YoelEigner commented 11 months ago

Thanks @callihann, I'm using that as well but it doesn't work 100% of the time for some reason