1
0
Fork 0
Postman-To-PDF/utils/pdf-generator.js

27 lines
678 B
JavaScript

const pdf = require('html-pdf');
module.exports = function pdfGenerator(html, file, outputPath) {
const filepath = outputPath + "/" + file;
const options = {
format: 'A4',
timeout: 60000,
"border": "5mm",
"height": '297mm',
"footer": {
"height": "5mm",
"contents": {
default: '<span style="display: block; color: #444; font-size: 15px; text-align: right; width: 100%;">{{page}} / {{pages}}</span>',
}
},
};
console.log("Generate PDF");
pdf.create(html, options).toFile(filepath, function(err, res) {
if (err) {
console.log(err);
}
if (res) {
console.log("End generation PDF");
}
});
};