From 57bf3af60d1779da6478042d622a55119b6a720e Mon Sep 17 00:00:00 2001 From: Liam Keegan Date: Mon, 9 Dec 2024 09:57:19 +0100 Subject: [PATCH] add header to first page, refactor --- src/lib/components/ApplicationForm.svelte | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib/components/ApplicationForm.svelte b/src/lib/components/ApplicationForm.svelte index 8f4d217..4e3cbf7 100644 --- a/src/lib/components/ApplicationForm.svelte +++ b/src/lib/components/ApplicationForm.svelte @@ -62,9 +62,19 @@ function writeLine(page: PDFPage, text: string, yPos: number): number { return yPos + yPadding; } +function writeHeader(page: PDFPage, text: string) { + page.drawText(`${text} - ${position} - ${name}`, { + x: 5, + y: page.getSize().height - 12, + size: 10, + color: rgb(0.227, 0.62, 0.749), + }); +} + async function createPdfFrontPage() { const pdfDoc = await PDFDocument.create(); const page = pdfDoc.addPage(); + writeHeader(page, "Application"); let yPos = 80; yPos = writeLine(page, "SSC Application", yPos); yPos = writeLine(page, `Position: ${position}`, yPos); @@ -94,12 +104,7 @@ async function addPdf( uploadedDoc.getPageIndices(), )) { let newPage = pdfDoc.addPage(page); - newPage.drawText(`${pdfId} - ${position} - ${name}`, { - x: 5, - y: page.getSize().height - 12, - size: 10, - color: rgb(0.227, 0.62, 0.749), - }); + writeHeader(newPage, pdfId); } }