feat(pdf): drawFooter with brand from runtime config

This commit is contained in:
Bastien Chanot committed 2026-05-18 21:45:26 +02:00
1 parent 099ebf326b
commit 6cbc6ce328
1 file changed
+23 -10
+23 -10
View File
@@ -1,15 +1,28 @@
import type { PDFPage } from 'pdf-lib'
import { rgb, type PDFPage } from 'pdf-lib'
import type { EmbeddedFonts } from '@/pdf/fonts'
import { appConfig } from '@/config/env'
import { formatDateFr, todayIso } from '@/lib/dates'
const MARGIN_X = 36
const FOOTER_Y = 28
/**
* Draws the page footer: brand name (from config), export date, page x/y.
* Brand name comes from env-driven appConfig — never hardcoded.
*/
export function drawFooter(
_page: PDFPage,
_fonts: EmbeddedFonts,
_pageNumber: number,
_totalPages: number,
page: PDFPage,
fonts: EmbeddedFonts,
pageNumber: number,
totalPages: number,
): void {
throw new Error('not implemented')
const { width } = page.getSize()
const muted = rgb(0.42, 0.39, 0.35)
const left = appConfig.footerName
const center = `Exporté le ${formatDateFr(todayIso())}`
const right = `${pageNumber} / ${totalPages}`
page.drawText(left, { x: MARGIN_X, y: FOOTER_Y, size: 9, font: fonts.bodyRegular, color: muted })
const centerW = fonts.bodyRegular.widthOfTextAtSize(center, 9)
page.drawText(center, { x: (width - centerW) / 2, y: FOOTER_Y, size: 9, font: fonts.bodyRegular, color: muted })
const rightW = fonts.bodyRegular.widthOfTextAtSize(right, 9)
page.drawText(right, { x: width - MARGIN_X - rightW, y: FOOTER_Y, size: 9, font: fonts.bodyRegular, color: muted })
}