From 5dcdc29a1801ddf20a5aa4f3a22f53955bc8d674 Mon Sep 17 00:00:00 2001 From: flfeders Date: Wed, 22 Jul 2026 19:45:01 +0200 Subject: [PATCH] Place invoice payment QR code bottom right --- backend/src/utils/pdf.ts | 51 ++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/backend/src/utils/pdf.ts b/backend/src/utils/pdf.ts index 21caa5d..eae891b 100644 --- a/backend/src/utils/pdf.ts +++ b/backend/src/utils/pdf.ts @@ -981,31 +981,36 @@ export const createInvoicePDF = async (server:FastifyInstance, returnMode, invoi color: rgb(0, 0, 0), lineHeight: 10, opacity: 1, - maxWidth: paymentQrCode ? 360 : 500 + maxWidth: 500 + }) + } + + if (paymentQrCode) { + const lastPage = pages[pages.length - 1] + const mm = 2.83 + const qrSize = 32 * mm + const rightMargin = 20 * mm + const bottomMargin = 20 * mm + const qrX = lastPage.getWidth() - rightMargin - qrSize + const qrY = bottomMargin + + lastPage.drawText("Überweisung per QR-Code", { + x: qrX, + y: qrY + qrSize + 7, + size: 8, + color: rgb(0, 0, 0), + lineHeight: 8, + opacity: 1, + maxWidth: qrSize, + font: fontBold, }) - if (paymentQrCode) { - const qrSize = 32 * 2.83 - const qrPosition = getCoordinatesForPDFLib(166, rowHeight + endTextDiff + (invoiceData.totalArray.length - 3) * 8 - 1, page1) - - pages[pageCounter - 1].drawText("Überweisung per QR-Code", { - y: qrPosition.y + qrSize + 7, - x: getCoordinatesForPDFLib(166, 0, page1).x, - size: 8, - color: rgb(0, 0, 0), - lineHeight: 8, - opacity: 1, - maxWidth: 120, - font: fontBold, - }) - - pages[pageCounter - 1].drawImage(paymentQrCode, { - x: qrPosition.x, - y: qrPosition.y, - width: qrSize, - height: qrSize, - }) - } + lastPage.drawImage(paymentQrCode, { + x: qrX, + y: qrY, + width: qrSize, + height: qrSize, + }) } return await pdfDoc.saveAsBase64()