"fix-pdf-normalize-to-a4"

This commit is contained in:
deploy
2026-04-29 15:22:40 +02:00
parent e9bee29a8a
commit 7e49de3d59
+8 -2
View File
@@ -34,8 +34,14 @@ export async function generateInvoicePdf(
? await pdfDoc.embedPng(imgBytes)
: await pdfDoc.embedJpg(imgBytes);
const imgW = image.width;
const imgH = image.height;
// Normaliser à une largeur A4 (595pt) pour que la section invités
// soit visible. Sans normalisation, image.width est en pixels
// (ex. 3024px), ce qui donne une page de 42 pouces de large et
// rend la section invités (~134pt) imperceptible en bas de page.
const PAGE_W = 595;
const scale = PAGE_W / image.width;
const imgW = PAGE_W;
const imgH = Math.round(image.height * scale);
const isLast = idx === imagePaths.length - 1;
const addList = isLast && guests.length > 0;