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

Header and footer are unusually small #5029

Closed
hahyes opened this issue Jan 14, 2021 · 5 comments
Closed

Header and footer are unusually small #5029

hahyes opened this issue Jan 14, 2021 · 5 comments

Comments

@hahyes
Copy link

hahyes commented Jan 14, 2021

Hi there,

I started doing some tests with Playwright Sharp and I needed to add header and footer. I ended with code like this...

using var playwright = await Playwright.CreateAsync();
await using var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewPageAsync();
await page.GoToAsync("https://www.google.com");
await page.GetPdfAsync(
    Environment.CurrentDirectory + "\\try.pdf",
    margin: new Margin() { Bottom = "0.2in", Left = "0.2in", Right = "0.2in", Top = "0.2in" },
    headerTemplate: "<h1>header</h1>",
    footerTemplate: "<h1>Footer</h1>",
    displayHeaderFooter: true);

Problem is, header and footer are very small. I don't know why. I tried some HTML templates I had, I tried code above. It's always like this.
Second problem is, when I would try to make it bigger with font-size style for example, text become bigger but page content except margin space seems to be over header and footer (like wrong zindex or something). What is happening?
Is it Playwright Sharp or main library issue?

@hahyes
Copy link
Author

hahyes commented Jan 14, 2021

try.pdf

Both problems you can see here.

@avodovnik avodovnik transferred this issue from microsoft/playwright-dotnet Jan 15, 2021
@avodovnik
Copy link
Contributor

avodovnik commented Jan 15, 2021

This happens in the Node version as well, so probably best if we look at it from that POV.

Repro:

const { chromium } = require('playwright');

(async () => {
    var browser = await chromium.launch();

    var page = await browser.newPage();
    await page.goto("https://www.google.com");
    await page.pdf({
        path: "try.pdf",
        headerTemplate: "<h1>Header</h1>",
        footerTemplate: "<h1>Footer</h1>",
        displayHeaderFooter: true,
        margin: { top: "0.2in", bottom: "0.2in", left: "0.2in", right: "0.2in" }
    });

    await browser.close();
})();

@pavelfeldman
Copy link
Member

@pavelfeldman
Copy link
Member

Closing as per suggestion above.

@akashlimbani
Copy link

How I can add it center of footer ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants