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.

cannot add background color to Header/Footer

See original GitHub issue

I’m trying to customize the header and footer. But I cannot add the background color to the footer. And footer size is not the same. This is what I’m trying to do. page.pdf({ path: 'test.pdf', format: 'a4', landscape: '!data.isPortrait', footerTemplate: '<div class="footer" style="height:75px;position: absolute;background- color:red;top:auto;left:0px;right:0px;bottom:0px;">\ </div>', displayHeaderFooter: true, margin: { top: "75px", bottom: "75px" } });

  • Puppeteer version:1.1.0
  • Platform / OS version:ubuntu 16.04
  • URLs (if applicable):
  • Node.js version:8.9 What is the expected result? Footer background color should be in red color. What happens instead? Footer background color is not changed.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

110reactions
Guruhbkcommented, Apr 7, 2018

I found the solution. To add background-color to header/footer or to the entire page in Puppeteer, we need to add an additional css property, -webkit-print-color-adjust: exact. Now it works fine.

12reactions
atmortensencommented, Oct 18, 2019

For people who find this from Google, you can also add printBackground: true https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#pagepdfoptions

Read more comments on GitHub >

github_iconTop Results From Across the Web

cannot add background color to Header/Footer in pdf
To add background-color to header/footer or to the page in Puppeteer, we need to add an additional css property, -webkit-print-color-adjust: ...
Read more >
Header & Footer Color change - Microsoft Community
I have a Header & footer that has a deep blue background & white text & after i click out of it the...
Read more >
Changing the color of the header / footer background
Hi, I've forgotten how to change the color of the header / footer background. Some templates have the header and footer color set...
Read more >
How do you change the header/footer colour on a single page?
I have CSS on the page to use a different logo in the header for just that page, but I can't get the...
Read more >
Topic: Getting same header, footer and background color as ...
Hi there. I tried searching a bit, but I can't seem to find a decent tutorial on how to use the WordPress header,...
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