This package compiles HTML documents with the corresponding data to save them as PDF files.
$ npm i @sofiand/invoice
Go to zup to know how templates work.
Go to form-data-to-pdf to get FileBuffer interface.
const invoicejs = require('@sofiand/invoice');
let result;
// template is the converted template as string.
const template = '<html>...';
// data is a list where each element contains the information required by template.
const data = [
{
lastname: 'Gilbert',
firstname: 'Montagnard',
adress: 'Somewhere',
params: [
{
name: 'premier param',
value: 'première valeur'
},
{
name: 'second param',
value: 'seconde valeur'
}
]
}
];
main();
// Display:
// [
// {
// name: 'Gilbert Montagnard',
// pathOfsavedFile: 'C:\\Users\\Me\\Documents\\Gilbert-Montagnard1616428271017.pdf'
// }
// ]
async function main() {
try {
result = await invoicejs.getAndSaveInvoice(
template,
data,
{toSaveFiles: 'C:/Users/Me/Documents'}
);
console.log(result);
} catch(error) {
throw new Error(error);
}
}
Generated using TypeDoc