footerTemplate and headerTemplate don't use body styles
See original GitHub issueTell us about your environment:
Puppeteer version: 1.0.0 Platform / OS version: Linux Mint 18.3 Node.js version: 8.9.4
What steps will reproduce the problem?
I have a piece of code i use to generate pdf reports from html documents:
const page = await browser.newPage();
await page.goto(file, { waitUntil: "networkidle0", timeout: 100000 });
const default_options = {
format: "A4",
printBackground: true
};
const filename = `file-${uuid()}.pdf`;
const final_options = Object.assign({}, default_options, { path: filename }, options);
console.log(final_options);
await page.pdf(final_options);
await page.close();
file
is a link to a local html file. In this file head, I load specific fonts that I need for the document.
Inside of the options
, I pass the templates for headers and footers:
options: {
headerTemplate: "<p></p>",
footerTemplate: "<div class=\"footer\" style=\"font-size: 10px;color: #999; margin: 15px 0;clear:both; position: relative; top: 20px;font-family:my-font\"><p>Footer text</p></div>",
displayHeaderFooter: true,
margin: {
top: "100px",
bottom: "200px"
}
}
What is the expected result?
I would expect the footer to use the font loaded in the html body.
What happens instead?
The footer is looking into my system for the first font that could correspond the name provided and put this one instead. If the font is not installed on the system, it is using a default one.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:80
- Comments:43
Top Results From Across the Web
puppeteer header and footertemplate doesnt work
Please try the following templates: headerTemplate: '<span style="font-size: 30px; width: 200px; height: 200px; background-color: black; ...
Read more >Using the Puppeteer Header Template with Images and ...
Learn how to use Puppeteer header templates and how we customized them with our service to make it easier and more feature rich....
Read more >How can a control in a repeater HeaderTemplate or ... - MSDN
Hi,. I'm trying to use an UpdatePanel with a Repeater, where ImageButton controls in the repeater header and template footer templates cause a ......
Read more >columns.footerTemplate - API Reference - Kendo UI Grid
footerTemplate String|Function. The template which renders the footer table cell for the column. The fields which can be used in the template are:...
Read more >Header and Footer in Xamarin ListView (SfListView)
HeaderTemplate and SfListView.FooterTemplate properties. XAML; C#. <ContentPage xmlns:syncfusion="clr-namespace:Syncfusion.ListView.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I also noticed that if you stick a
style
tag in your header/footer templates, the CSS doesn’t all work right. Font sizes are different, custom font family is not changeable it seems, etc, it’s weird.Is it possible to use custom font family in footer template? I’ve tried adding <style> tags in the string and classes with styles in a styles.css file but nothing seems to work.