A
Anonymous

Invoice Generator - Copy this Angular, Tailwind Component to your project

voici le code generatePDF(action = 'open') { let docDefinition = { content: [ { text: `Facture N°: ${this.vente.facture.numero}`, alignment: 'center', italics: false, fontWeight: 'bold', fontSize: 16, margin: [0, 0, 0, 15] }, { columns: [ [ { text: `Service: ${this.vente.service.nom}`, style: 'header' }, { text: `Télèphone: (+221) ${this.vente.service.telephone}`, style: 'header' }, ], [{ text: `Facture N°: ${this.vente.facture.numero}`, alignment: 'right', italics: true}, { text: `Date: ${new Date().toLocaleString()}`, alignment: 'right' }, ], ] }, { text: 'Détails Client', style: 'sectionHeader' }, { columns: [ [ { text: `Nom Client: ${this.vente.client.nomComplet}`, style: 'header' }, { text: `Telephone Client: ${this.vente.client.telephone}`, style: 'header' }, ], ] }, { table: { headerRows: 1, widths: ['*', 'auto', 'auto', 'auto'], body: [ [{text: 'Produit',bold: true, fontSize: 14 }, {text: 'Prix',bold: true, fontSize: 14 }, {text:'Quantité',bold: true, fontSize: 14 }, {text:'Montant',bold: true, fontSize: 14}], ...this.vente.produitVentes.map(p => ([p.produit.nom, p.prixUnitaire + ' FCFA', p.quantite, (p.prixUnitaire * p.quantite).toFixed(2) + ' FCFA'])), [{text: 'Montant Total', colSpan: 3, bold: true}, {}, {}, this.vente.produitVentes.reduce((sum, p)=> sum + p.montant, 0).toFixed(2) + ' FCFA'] ] } }, { columns: [ [{ qr: `${this.vente.facture.numero}`, fit: '50', margin: [15, 15 ,0, 0] }], [{ text: `Signature`, alignment: 'right', fontSize: 16, bold: true, decoration: 'underline', italics: true, margin: [0, 15 ,15, 0] }, ], ] }, ], styles: { sectionHeader: { bold: true, decoration: 'underline', fontSize: 14, margin: [0, 15,0, 0] } } }; if(action==='download'){ pdfMake.createPdf(docDefinition).download(); }else if(action === 'print'){ pdfMake.createPdf(docDefinition).print(); }else{ pdfMake.createPdf(docDefinition).open(); } }

Prompt
Component Preview

About

Invoice Generator - Create professional invoices effortlessly with customizable templates, auto-calculations, and PDF export, built wit. Copy template now!

Share

Last updated 1 month ago