feat: add config-driven jsPDF invoice renderer with all header and table styles

This commit is contained in:
Your Name
2026-02-18 13:26:11 +02:00
parent 185b20cab2
commit b05bd415fb
2 changed files with 1158 additions and 0 deletions

37
src/utils/invoicePdf.ts Normal file
View File

@@ -0,0 +1,37 @@
import { jsPDF } from 'jspdf'
import type { Invoice } from '../stores/invoices'
import type { Client } from '../stores/clients'
import { renderInvoicePdf, type BusinessInfo } from './invoicePdfRenderer'
import { getTemplateById } from './invoiceTemplates'
/**
* Invoice item interface for line items on the invoice
*/
export interface InvoiceItem {
id?: number
description: string
quantity: number
rate: number
amount: number
}
/**
* Generate a PDF invoice using a template
* @param invoice - The invoice data
* @param client - The client data
* @param items - The invoice line items
* @param templateId - Template ID to use (defaults to 'clean-minimal')
* @param businessInfo - Optional business identity info
* @returns The generated jsPDF document
*/
export function generateInvoicePdf(
invoice: Invoice,
client: Client,
items: InvoiceItem[],
templateId: string = 'clean-minimal',
businessInfo?: BusinessInfo,
): jsPDF {
const config = getTemplateById(templateId)
const info: BusinessInfo = businessInfo || { name: '', address: '', email: '', phone: '', logo: '' }
return renderInvoicePdf(config, invoice, client, items, info)
}

File diff suppressed because it is too large Load Diff