UNPKG

@casoon/invoice-generator

Version:

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

38 lines (30 loc) 1.04 kB
import PDFKit from 'pdfkit'; import { Invoice } from '../../types/invoice.types'; export class ClosingSection { private doc: PDFKit.PDFDocument; private currentY: number; constructor(doc: PDFKit.PDFDocument, currentY: number) { this.doc = doc; this.currentY = currentY; } /** * Bereich 4: Grußformel * DIN 5008: Mindestens 20mm Abstand zur Tabelle */ public draw(invoice: Invoice): number { // Zahlungsinformationen im korrekten Format const paymentText = `Zahlbar ohne Abzug bis zum ${invoice.paymentInfo.dueDate}.`; this.doc.font('Helvetica') .fontSize(10) .text(paymentText, 50, this.currentY, { continued: false }); this.currentY += 30; // Grußformel this.doc.font('Helvetica') .fontSize(10) .text('Mit freundlichen Grüßen', 50, this.currentY, { continued: false }); this.currentY += 15; this.doc.text(invoice.sender.name, 50, this.currentY, { continued: false }); this.currentY += 40; return this.currentY; } }