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
You can use the headerTemplate and footerTemaplate parameters in printToPDF to customize the header and footer when printing to PDF.
headerTemplate and footerTemaplate accept valid HTML markup, and you can use the following classes to inject printing values into your HTML elements:
date - will inject the current date in printable format into the HTML element containing the classtitle - document titleurl - document locationpageNumber - current page numbertotalPages - total number of pagesFor example, to print the page number and total number of pages:
Page.printToPDF({
displayHeaderFooter: true,
footerTemplate: " out of "
})
(At the time, this was not possible to achieve with Chrome DevTools.)
According to this forum, there is currently no way to do this in google chrome. All you can do is turn the header/footer on or off. This is indicated by the comment:
Currently there isn't a way to edit the header when printing a document. You can currently only turn the header and footer on or off which includes the date, name of the web page, the page URL and how many pages the document you're printing. You may want to check out the Chrome Web Store to see if there are any handy third party extensions that you can install on Chrome that may fit what you're looking for in terms of printing -- Source There may be third-party extensions to get the functionality you are looking for, or as you suggest, you can use JavaScript to append the elements you want to print.