Skip to content
Snippets Groups Projects
Commit e266b702 authored by Jonas Zohren's avatar Jonas Zohren 💬
Browse files

use german date in pdf form

parent aa860ca6
No related branches found
No related tags found
No related merge requests found
Pipeline #156097 passed with stage
in 47 seconds
......@@ -8,6 +8,17 @@ import { UbuntuRBase64 } from './fonts';
// Fetch the Ubuntu font
const ubuntuFontBuf = Uint8Array.from(atob(UbuntuRBase64), (c) => c.charCodeAt(0));
function currentGermanDate() {
const now = new Date();
return (
now.getDate().toString().padStart(2, '0') +
'.' +
now.getMonth().toString().padStart(2, '0') +
'.' +
now.getFullYear().toString()
);
}
export async function renderSummaryToPdf({
title,
payoutInfo,
......@@ -20,7 +31,7 @@ export async function renderSummaryToPdf({
pdfDoc.setTitle('Kostenabrechnung ' + title);
pdfForm.getTextField('subject').setText(title);
pdfForm.getTextField('date').setText(new Date().toUTCString());
pdfForm.getTextField('date').setText(currentGermanDate());
spendingItems.forEach((spendingItem, idx) => {
const counter = idx + 1;
const fieldIdPrefix = 'item.' + counter + '.';
......@@ -156,19 +167,20 @@ function drawSignatureBox(titlePage: PDFPage, pageHeight: number, ubuntuFont: PD
});
}
async function addSignatureToPage(pdfDoc: PDFDocument, page: PDFPage, signatureImageBytes: Uint8Array) {
async function addSignatureToPage(
pdfDoc: PDFDocument,
page: PDFPage,
signatureImageBytes: Uint8Array
) {
const image = await pdfDoc.embedPng(signatureImageBytes);
page.drawImage(image, {
x: 60,
y: PageSizes.A4[1] - 800,
width: 300,
height: 80,
})
height: 80
});
}
async function drawTitleTable(
pdfDoc: PDFDocument,
page: PDFPage,
......@@ -331,8 +343,8 @@ async function addReceiptPages(spendingItems: SpendingItem[], pdfDoc: PDFDocumen
if (receipt.type == 'application/pdf') {
const pdfBytes = await receipt.arrayBuffer();
const receiptPdfDoc = await PDFDocument.load(pdfBytes)
const receiptPages = await pdfDoc.embedPages(receiptPdfDoc.getPages())
const receiptPdfDoc = await PDFDocument.load(pdfBytes);
const receiptPages = await pdfDoc.embedPages(receiptPdfDoc.getPages());
let insertedPageCounter = 0;
for (const receiptPage of receiptPages) {
......@@ -357,4 +369,4 @@ async function addReceiptPages(spendingItems: SpendingItem[], pdfDoc: PDFDocumen
}
}
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment