I\'m trying to use Google Chrome as a replacement of PhantomJS to render HTML into PDF. So far it\'s been working well for me. The only issue I have that I have not found an
This is an update/answer to the question. As of Chromium 64 it is possible using the headerTemplate and footerTemplate parameters to printToPDF
Using chrome remote interface here's example code that should work:
return new Promise(async function (resolve, reject) {
const url = "";
const [tab] = await Cdp.List()
const client = await Cdp({ host: '127.0.0.1', target: tab });
await Promise.all([
Network.enable(),
Page.enable()
]);
Page.loadEventFired(function () {
setTimeout(function () {
//https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-printToPDF
resolve(Page.printToPDF({
displayHeaderFooter:true,
footerTemplate: " of "
})));
}, 3000);
});
await Page.navigate({ url });
};