question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

footerTemplate and headerTemplate don't use body styles

See original GitHub issue

Tell 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:open
  • Created 6 years ago
  • Reactions:80
  • Comments:43

github_iconTop GitHub Comments

23reactions
rclaicommented, Mar 30, 2018

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.

10reactions
TylerJAllencommented, May 7, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found