Ansichtsausweis

This commit is contained in:
Moritz Utcke
2025-03-16 18:01:28 -03:00
parent cd7fce3b1b
commit 310794a049

View File

@@ -14,7 +14,7 @@ import { PERSISTENT_DIR } from "#lib/server/constants.js";
/* -------------------------------- Pdf Tools ------------------------------- */ /* -------------------------------- Pdf Tools ------------------------------- */
export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohnenClient, aufnahme: AufnahmeClient, objekt: ObjektClient, bilder: BildClient[], user: BenutzerClient) { export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohnenClient, aufnahme: AufnahmeClient, objekt: ObjektClient, bilder: BildClient[], user: BenutzerClient) {
const VerbrauchsausweisWohnenGEG2024PDF = fs.readFileSync(new URL("../../../public/pdf/templates/GEG24_Wohngebaeude_ohne_pfeile_form.pdf", import.meta.url), "base64"); const VerbrauchsausweisWohnenGEG2024PDF = fs.readFileSync(new URL("../../../public/pdf/templates/GEG24_Wohngebaeude_ohne_pfeile.pdf", import.meta.url), "base64");
const pdf = await PDFDocument.load(VerbrauchsausweisWohnenGEG2024PDF) const pdf = await PDFDocument.load(VerbrauchsausweisWohnenGEG2024PDF)
const pages = pdf.getPages() const pages = pdf.getPages()
@@ -28,26 +28,6 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
const font = await pdf.embedFont(StandardFonts.Helvetica) const font = await pdf.embedFont(StandardFonts.Helvetica)
const bold = await pdf.embedFont(StandardFonts.HelveticaBold) const bold = await pdf.embedFont(StandardFonts.HelveticaBold)
const form = pdf.getForm()
form.updateFieldAppearances(font)
const fillFormField = (name: string, value: string, fontSize: number = 8, alignment: TextAlignment = TextAlignment.Left) => {
const field = form.getTextField(name)
field.setFontSize(fontSize)
field.setText(value)
field.setAlignment(alignment)
}
const toggleCheck = (name: string, checked: boolean = true) => {
const field = form.getCheckBox(name)
if (checked) {
field.check()
} else {
field.uncheck()
}
}
pages[0].drawText(aufnahme.gebaeudetyp || "", { pages[0].drawText(aufnahme.gebaeudetyp || "", {
x: 211, x: 211,
y: height - 166, y: height - 166,
@@ -612,7 +592,5 @@ export async function pdfVerbrauchsausweisWohnen(ausweis: VerbrauchsausweisWohne
addDatumGEG(page, font) addDatumGEG(page, font)
} }
pdf.getForm().flatten()
return pdf.save(); return pdf.save();
} }