Skip to content

Instantly share code, notes, and snippets.

@asessa
Created June 7, 2015 23:33
Show Gist options
  • Save asessa/bf389070d76aaaf3987b to your computer and use it in GitHub Desktop.
Save asessa/bf389070d76aaaf3987b to your computer and use it in GitHub Desktop.
node-html-pdf header/footer test
var pdf = require('html-pdf');
var options = {
'format': 'A4',
'border': '1cm',
'header': {
'height':'5cm'
},
'footer': {
'footer': '5cm'
}
}
var html = '<body>' +
' <div id="pageHeader"><img src="https://www.google.com/images/srpr/logo11w.png"></div>' +
' <div id="pageContent">' +
' this is the main content on page 1' +
' <p style="page-break-after:always;"></p>' +
' this content goes on page 2 to test header/footer' +
' </div>' +
' <div id="pageFooter">' +
' <img src="https://www.google.com/images/srpr/logo11w.png">' +
' </div>' +
'</body>';
pdf.create(html, options).toFile(function(err, res) {
if (err) return console.log(err);
console.log(res);
});
@elSuperRiton
Copy link

Same issue with any assets in the header/footer ( using the html pageHeader include )
I've used the "base" option to set an absolute path for the public folder.
The images and the fonts are working properly in the page content but none are working in pageHeader and pageFooter.
I can confirm that images are working using an external image.

Any workaround in mind ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment