UNPKG

@casoon/invoice-generator

Version:

Generate PDF invoices, XRechnung XML, and ZUGFeRD PDF/A-3 from JSON data with TypeScript support

67 lines 3.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FooterSection = void 0; class FooterSection { constructor(doc, currentY) { this.pageHeight = 842; // A4 Höhe in Punkten this.footerY = 720; // Höher positioniert: 842 - 122 (Footer-Höhe) this.doc = doc; this.currentY = currentY; } /** * Wiederkehrender Footer * DIN 5008: Mindestens 15mm vom unteren Rand * Fixe Position am unteren Seitenrand */ draw(invoice) { // Zeichne Footer auf jeder Seite this.drawFooterOnAllPages(invoice); // Aktualisiere currentY für den nächsten Bereich return this.currentY; } drawFooterOnAllPages(invoice) { // Hole alle Seiten des Dokuments const pageRange = this.doc.bufferedPageRange(); for (let pageIndex = pageRange.start; pageIndex < pageRange.start + pageRange.count; pageIndex++) { // Wechsle zur entsprechenden Seite this.doc.switchToPage(pageIndex); // Zeichne Footer auf dieser Seite this.drawFooterOnPage(invoice); } } drawFooterOnPage(invoice) { // Keine Trennlinie vor Footer const footerStartY = this.footerY + 20; // Vier-Spalten-Footer mit gleichmäßigen Spalten const totalWidth = 500; // 550 - 50 (Rand) const colWidth = totalWidth / 4; // 125px pro Spalte const colSpacing = 0; // Kein zusätzlicher Abstand zwischen Spalten // Spalte 1 - Firmeninfo this.doc.font('Helvetica-Bold') .fontSize(7) // Kleinere Schrift .text(invoice.sender.company || invoice.sender.name, 50, footerStartY, { continued: false }) .font('Helvetica') .text(invoice.sender.name, 50, footerStartY + 12, { continued: false }) .text(invoice.sender.address.street, 50, footerStartY + 24, { continued: false }) .text(`${invoice.sender.address.postalCode} ${invoice.sender.address.city}`, 50, footerStartY + 36, { continued: false }); // Spalte 2 - Kontaktdaten this.doc.fontSize(7) // Kleinere Schrift .text(`Tel.: ${invoice.sender.contactInfo.phone}`, 50 + colWidth, footerStartY, { continued: false }) .text(`Email: ${invoice.sender.contactInfo.email}`, 50 + colWidth, footerStartY + 12, { continued: false }) .text(`Web: ${invoice.sender.contactInfo.website}`, 50 + colWidth, footerStartY + 24, { continued: false }); // Spalte 3 - Geschäftsinhaber und USt-IdNr. this.doc.fontSize(7) // Kleinere Schrift .text('Geschäftsinhaber:', 50 + 2 * colWidth, footerStartY, { continued: false }) .text(invoice.sender.businessOwner || '', 50 + 2 * colWidth, footerStartY + 12, { continued: false }) .text('USt-IdNr.:', 50 + 2 * colWidth, footerStartY + 24, { continued: false }) .text(invoice.sender.vatId || '', 50 + 2 * colWidth, footerStartY + 36, { continued: false }); // Spalte 4 - Bankdaten this.doc.fontSize(7) // Kleinere Schrift .text(`Bank: ${invoice.paymentInfo.bank}`, 50 + 3 * colWidth, footerStartY, { continued: false }) .text(`Kontoinhaber: ${invoice.paymentInfo.accountHolder}`, 50 + 3 * colWidth, footerStartY + 12, { continued: false }) .text(`IBAN: ${invoice.paymentInfo.iban}`, 50 + 3 * colWidth, footerStartY + 24, { continued: false }) .text(`BIC/SWIFT-Code: ${invoice.paymentInfo.bic}`, 50 + 3 * colWidth, footerStartY + 36, { continued: false }); } } exports.FooterSection = FooterSection; //# sourceMappingURL=footer-section.js.map