-
Notifications
You must be signed in to change notification settings - Fork 68
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
toebes.com - Print preview issues #139133
Comments
If you need me to generate a smaller example showing individual problems, don't hesitate to ask. |
Thanks for the report. I was able to reproduce in Firefox Nightly, and Firefox Release. Reproducible issues are moved to our Bugzilla component; please see: https://bugzilla.mozilla.org/show_bug.cgi?id=1907822 Closing as moved. [qa_29/2024] |
Hi @toebes - I'm only seeing one difference (aside from font subtleties) between Firefox and Chrome, and it's a case where Firefox is honoring a forced pagebreak that the content is requesting, and Chrome is ignoring it (near the top of page 2). I'm not entirely sure which behavior is correct -- I filed https://bugzilla.mozilla.org/show_bug.cgi?id=1917145 on it with a reduced testcase -- but in the meantime I think you can avoid that difference by removing <div class="question pagebreak"> With that addressed, I'm not seeing any other substantial differences. Would you mind retesting and seeing if you're still seeing differences between Firefox and Chrome? And if you are, maybe share PDFs and/or screenshots to highlight the issues? Thanks! |
Remember that this is a reduced case. I didn't want to burden you with the 20 page version. Removing the pagebreak breaks lots of cases and is there to ensure that everything is paginated correctly. In theory the pagebreak should be innocuous when you are already at the start of a page. To show the differences, I generated this from your test case: here's the Firefox version which ends up as 5 pages and if you look at the first page, the table is cut off to the right. Here's the Chrome version which is only 3 pages (as expected). Please let me know what else I can provide. If you want to see the extreme case you can go to: toebes.com/codebusters/TestManage.html?importURL=Samples/NC_C_Regional_1_2024.json |
Sure -- I wasn't suggesting you remove all requested pagebreaks. :) Let me go into a bit more detail about why that one is troublesome... In this particular case, the testcase is essentially requesting two pagebreaks in a row. Specifically, right now the content on the original reduced testcase looks like this: <div class="page">
<div class="head">2024 Science Olympiad National Codebusters Division B</div>
<div class="headright">Team Number:_B_________</div>
<div class="foot">Page 1</div>
<div class="question pagebreak"> And here, both the .page {
[...]
page-break-before: always;
[...]
}
[...]
.pagebreak {
page-break-before: always;
} This means the content is essentially requesting a page-break before each of those elements. That's why the first bit of content (notably the I think technically Chrome is correct because the second forced-pagebreak here is supposed to be propagated to its parent since it's the first child (or the first non-abspos child, at least), which means the parent is essentially requesting two pagebreaks at the exact same spot (once explicitly, one propagated from the child), which results in a single break. At some point Firefox and Safari will implement those page-break propagation rules (maybe in this Firefox bug -- forced page-breaks in Firefox are a bit hairy and are something we'd like to rework, but we probably won't get to it in the next few months at least). In the meantime, if you're looking for ways to work around this issue, you might try avoiding this sort of "double-page-break-request" where the content has two Hopefully that makes sense and might be workable, if you're interested in ideas for workarounds. Thanks again for the bug report! |
Thanks for sharing this -- so for me, in order to get that "cut-off-on-the-right" issue (and in order to get a 5th page), I have to activate a non-default setting -- I have to choose "Scale: 100%" in the Firefox print dialog** (in the "More Settings" expandable section). Could you check if you have that setting toggled? If so -- I'll bet things improve for you with the "Scale: Fit to Page Width", as shown here: |
Thanks. So, good news -- analyzing that extreme case, I can get Firefox to match Chrome with fairly-minimal workarounds. Details:
.page > .pagebreak { break-before: initial !important; }
.page { break-after: initial !important; } Here's the Chrome output that I get from this document: Here's the output that I get with Firefox with the above two CSS styles added to the stylesheet (to override some of the styles that are otherwise requesting double-pagebreaks that Firefox doesn't currently coalesce together): |
(side note: given that "Scale: Fit to Page Width" and "Scale: 100%" produce different results, that's actually a good clue that the page here is using some explicitly-sized content that's wider than the available space on the page. That's why stuff gets clipped when you ask for 100% scale, and why it gets scaled down to avoid clipping when you use the default "Fit to Page Width". Specifically looking at the clipped elements on the first page in the reduced testcase, we have this for the "nameline" (the section where "Team numb[...]" gets clipped): table.nameline {
[...]
width: 50rem; And we have this defining the size of the scoring table below that (note that there are 5 table.testscores th {
[...]
width: 11rem;
}
And in Firefox at least, 800px is slightly wider than the available width on a US Letter page with Chrome has an interesting behavior where they seem to force "fit to page width" even if you try to choose a large scale factor. But if you try reducing the scale factor, you can see that ~92% scale is where 800px exactly fills the page area (with default margins), and they seem to refuse to scale up beyond that (including to 100%) even if you ask them to. |
So, bottom line, this is my diagnosis of what's going on:
|
@toebes I hope the above helps, particularly my notes with good news on the extreme case. Let me know if you have further questions about what's going on here; otherwise I'm hopeful that it's not too tricky to work around this in the meantime (e.g. using CSS similar to my |
Some great observations! Thank you. I've fixed the width issues on that score table (thank you for pointing that out) and it works "better" as long as they specify scale to width. Scale to 100% still doesn't behave as expected (you can see the page number on the subsequent page). I hope to get that pushed out to production after a bit more testing. One thing that I did want to point out is that the .page style has a .page {
page-break-inside: avoid;
padding: 0.5in 0in 0.25in 0in !important;
position: relative;
width: 100%;
height: 100%;
page-break-after: always;
page-break-before: always;
} |
That's good news, though if you're still seeing a difference between those configurations in Firefox, then that's an indication that you've still got some element with too large of a specified width to actually fit on the page. If everything is fitting horizontally, then "Fit to Page Width" and "scale: 100%" would produce exactly the same layout. (Note: Chrome has a bug in these scale settings, meaning their "scale:100%" layout can't be relied on -- so if you're seeing good results from them with
That indicates that your positioning for these page numbers is too large for them to fit in the available space on the page. (You happen to be getting lucky that "fit to page width" is having to scale stuff down, such that it happens to scale the heights enough to make stuff fit vertically too.) Looking at your original testcase, I can see that this is trivially happening with the "Page 2" text that you mentioned was being pushed to its own page when printed at 100% scale. Here's the relevant CSS from your testcase: @page {
margin: 0.5cm;
}
.page .foot {
height: 0.25in;
[...]
position: absolute;
[...]
top: 10.5in;
}
.page .foot {
margin: 0.7em auto; Those various offsets are placing the Specifically, for a US Letter sheet of paper:
To avoid that overflowing page number, you need to use smaller
Yup, I saw that -- that turns out not to be relevant here. Quoting the spec, "...a ("page-break-inside: avoid" also can't save you in cases where the content is simply positioned at too far of an explicit offset to be able to fit on the same page, as is the case with the |
URL: https://toebes.com/codebusters/Samples/firefox_toebes_printing_example.html
Browser / Version: Firefox 128.0
Operating System: Windows 10
Tested Another Browser: Yes Chrome
Problem type: Something else
Description: Printing doesn't format correctly
Steps to Reproduce:
This is an extract of a sample case of the set of tools for Science Olympiad Code Busters (https://toebes.com/codebusters/) that generate and print tests.
When we print the tests using other browsers (Chrome, Edge) we are able to get consistent formatting and output such that the page fits on the sheet of paper and text is rendered cleanly. However, in the past year or so we have received complaints from Firefox users that it doesn't format and print well.
I have run through the W3c validator to ensure that the HTML is valid.
If you load the file in Firefox and then print, you will notice several issues:
Note that I have experimented with multiple options for the print scale and margins, for purposes of comparison I set the margins to .5" all around and forced the scale to 100% in all three browsers.
I've uploaded an image showing a side by side comparison of the rendered first page.
View the screenshot
Browser Configuration
From webcompat.com with ❤️
The text was updated successfully, but these errors were encountered: