1.1.0 • Published 5 years ago
xml2pdf v1.1.0
xml2pdf
This repo has been inspired from xml-pdf.
In addition to xml2pdf
CLI (see xml-pdf
for more info) this lib provides an async function to generate PDF from XML without accessing the filesystem (so that, for instance, it can be used in the browser):
Basic usage
const { xml2pdfAsync } = require('./index');
const xml = '...';
const options = {
template: '<main template>'
};
xml2pdfAsync(xml, options).then(res => {
// res is the pdf
}).catch(err => ...));
Header and Footer
const { xml2pdfAsync } = require('./index');
const xml = '...';
const options = {
template: '...',
header: {
height: '10mm', // see html-pdf height options
template: '<header template>'
},
footer: {
height: '10mm', // see html-pdf height options
template: '<footer template>'
}
};
xml2pdfAsync(xml, options).then(res => {
// res is the pdf
}).catch(err => ...));
See test
folder with header and footer examples.