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

preferCSSPageSize option for PDF generation doesn't do anything #6657

Open
cut2run opened this issue Dec 7, 2020 · 7 comments
Open

preferCSSPageSize option for PDF generation doesn't do anything #6657

cut2run opened this issue Dec 7, 2020 · 7 comments

Comments

@cut2run
Copy link

cut2run commented Dec 7, 2020

We have upgraded the Chromium 80.0.3987.0 - Puppeteer v2.1.0 to the newest Chromium 88.0.4298.0 - Puppeteer 5.5.0 to pursue the taggable PDF output. After the upgrade the following HTML ...

<html xmlns="http://www.w3.org/TR/REC-html40">
<head>
<style>
@page section
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.section
{page:section;}
</style>
</head>
<body>
<b>Test string before content</b>

<div class="section"><p>Content</p></div>

<b>Test string after content</b>
</body>
</html>

when converted to PDF produces 3 pages, one with before content, the second with content, and the third with after content. With the previous Puppeteer 2.1 we had, the same HTML was producing the single PDF page, which we would expect if preferCSSPageSize: false, which is the default by the way. I assume the option tells the converter to ignore @Page media.
Are there any changes to this PDF option? Is my assumption wrong (but in this case what does this option do for the given HTML)?
We have tried to set explicitly preferCSSPageSize, but it doesn't make any difference, we are getting 3 pages PDF all the time.

Please note: I am not asking how to modify HTML to get one page, I am completely aware of the page CSS property; I am asking what was changed over the versions, as well as clearly understand why @Page media suddenly start working when should be suppressed.

@cut2run
Copy link
Author

cut2run commented Jan 5, 2021

The Chromium team has confirmed the change in behavior as of version 83, which is starting from Puppeteer 3.1.0. (Issue 1160301: Print preview/save to PDF produces 3 pages long document). The change was intended and the page breaks are expected. This was implemented according to Named pages with page-orientation. So the cause right now is clear.

The question to the Puppeteer team is still open ... Why preferCSSPageSize PDF options flag set to false doesn't ignore @Page media styles? This looks like the valid bug of Puppeteer API.

As the comment, I can see thousands of open issues that nobody replies to. Is anyone even monitors this queue? The project looks like moving on, but nobody looks like cares about ongoing issues.

@manuelmeister
Copy link

That's a shame. Because the print preview in chrome browser is now correct with e.g. size: A4 landscape

@stale
Copy link

stale bot commented Jun 23, 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 23, 2022
@manuelmeister
Copy link

Still an issue

@stale stale bot removed the unconfirmed label Jun 24, 2022
@stale
Copy link

stale bot commented Aug 30, 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 Aug 30, 2022
@manuelmeister
Copy link

Still a problem

@mixman68
Copy link

The issue still exists, if a css specify a page size, puppeteer ignore format

{"path":"test.pdf","margin":{"top":"1cm","bottom":"1cm","left":"1cm","right":"1cm"},"scale":1,"format":"A4","printBackground":true,"landscape":true,"preferCSSPageSize":false}

@OrKoN OrKoN added the P3 label May 9, 2024
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

4 participants