htmltopdf
v0.0.10
Published
A node package to convert HTML to PDF, it supports sending in straight HTML and convert to PDF. It also supports sending in template in handlebars format with a data string and convert that to PDF
Downloads
267
Maintainers
Readme
author: Ólafur Aron Jóhannsson email: [email protected] website: https://www.olafuraron.is
Convert HTML sites to PDF with this simple package.
https://www.npmjs.com/package/htmltopdf
npm install htmltopdf
The output would be
if (process.argv.length > 2) { var pdfName = process.argv[2]; var html = process.argv[3];
if (pdfName.indexOf('.pdf') > 0) {
var htmlData = process.argv[4];
// If htmlData is valid
if (!!htmlData) {
htmltopdf.createFromTemplateData(html, htmlData, pdfName, function (err, success) {
if (success) {
console.log('Success creating ' + pdfName);
}
else {
console.log('Could not create PDF', err);
}
});
}
else {
htmltopdf.createFromHtml(html, pdfName, function (err, success) {
if (success) {
console.log('Success creating ' + pdfName);
}
else {
console.log('Could not create PDF', err);
}
});
}
}
}