with this code
let options = {
format: 'A4',
orientation: 'portrait',
border: '2mm',
header: {
height: '15mm',
contents: '<h4 style=" color: red;font-size:20;font-weight:800;text-align:center;">CUSTOMER INVOICE</h4>'
},
footer: {
height: '20mm',
contents: {
first: 'Cover page',
2: 'Second page',
default: '<span style="color: #444;">{{page}}</span>/<span>{{pages}}</span>',
last: 'Last Page'
}
}
}
// let PDF = await pdfMaster.generatePdf("template.hbs", { data }, options);
// const filePath = path.join(__dirname, '..', 'public', 'report.pdf');
// fs.writeFileSync(filePath, PDF);
// const templatePath = path.join(__dirname, 'template.hbs');
// // Compile Handlebars template
// const template = fs.readFileSync(templatePath, 'utf8');
// const compiledTemplate = handlebars.compile(template);
// const html = compiledTemplate({ data });
// console.log(html)
// // Options for PDF generation
// // Output PDF path
// const pdfPath = path.join(__dirname, '..', 'public', 'report.pdf');
// // Generate PDF from the compiled HTML
// pdf.create(html, options).toFile(pdfPath, (err) => {
// if (err) return console.error('Error generating PDF:', err);
// console.log('PDF generated successfully:', pdfPath);
// });
const html = fs.readFileSync(path.join(__dirname, 'template.html'), 'utf-8');
const document = {
html: html,
data: {
products: data
},
path: './docs/' + 'report.pdf'
}
pdf.create(document, options)
.then(res => {
console.log(res);
}).catch(error => {
console.log(error);
});
with this code i get pdf zoomed and my content is always out of the boundary i use bootstrap on my template html and the same template works fine with pdfmaster which as puppetere complication on my server side is there any way to solv the issue