Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default margins for header and footer are already added #3672

Closed
supriyapethkar opened this issue Dec 14, 2018 · 3 comments
Closed

Default margins for header and footer are already added #3672

supriyapethkar opened this issue Dec 14, 2018 · 3 comments

Comments

@supriyapethkar
Copy link

  • Puppeteer version: 1.11
  • Platform / OS version: MacOS Mojave
  • URLs (if applicable):
  • Node.js version: 8.9.4

What steps will reproduce the problem?

Please include code that reproduces the issue.
Below is my to code to generate the PDF:

await page.pdf({format: 'A4', displayHeaderFooter: true, headerTemplate: "<p class='header' style='font-size:12px; margin-top: 0px'>Hello Header</p>", footerTemplate: "<p class='footer' style='font-size:12px'>Hello Footer</p>", margin: {top: '100px', bottom: '100px'}});
I am basically trying to set the the top margin for the headerTemplate to 0. But it seems this style is not picked.

screen shot 2018-12-14 at 10 27 02 am

If I am giving margin-top value as some negative value, then the header seems to move upwards but it also applies the same margin value to it's left. Weird! ( I have applied the negative value to be -15px)

screen shot 2018-12-14 at 10 28 00 am

What is the expected result?
Header should be placed just below the start of page without any margins when I provide margin-top value as 0px. Also, if I give some negative value to margin-top, it should not apply the same value to margin-left, right and bottom.

What happens instead?
Header has some default margins even if we provide inline margins. Is it that Puppeteer internally adds some default margins to headerTemplate and footerTemplate ?

@SoerenWeber
Copy link

SoerenWeber commented Apr 22, 2019

This is related to #4132 . Chromium sets a default padding for header and footer. You can override it by selecting #header and #footer in your CSS.

@stale
Copy link

stale bot commented Jun 27, 2022

We're marking this issue as unconfirmed because it has not had recent activity and we weren't able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.

@stale stale bot added the unconfirmed label Jun 27, 2022
@stale
Copy link

stale bot commented Jul 27, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

@stale stale bot closed this as completed Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants