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

PDF restricted to single page in Letter when using body height: 100% #2100

Closed
michaellisitsa opened this issue Mar 18, 2024 · 1 comment
Closed
Labels
bug Existing features not working as expected
Milestone

Comments

@michaellisitsa
Copy link

michaellisitsa commented Mar 18, 2024

Going from v60.2 to v61, there is an issue with content being cut off at one page. It appears to be related to minor rounding errors in the "Letter" page size that causes the below newly added code to falsely think the content is overflowing.

I have made a replit here
https://replit.com/@mlisitsa/Python-Weasyprint-Bug-Print-Cut-to-Single-Page#script.py

The issue occurs when you have body {height: 100%} and @page {size: letter, margin: 15mm}.

The offending code looks to be bc97131, where the resume_at gets set to None, even though there is more content in the body tag.

elif stop:
if box.height != 'auto':
if position_y > box.position_y + box.height:
# Box heigh is fixed and it doesn’t overflow page, forget
# overflowing children.
resume_at = None
adjoining_margins = []
break

The resume_at then gets returned eventually to the make_page function

https://github.com/Kozea/WeasyPrint/blob/1ac1594cf3fe326ff09c4035d158b65fdc684b71/weasyprint/layout/page.py#L645-650

When I debugged it with Letter, you have the calculated position_y is approximately equal but ever so slightly bigger.

box.position_y + box.height
>> 999.3070866141732

position_y
>> 999.3070866141733

When using A4 page size, they are the same, and content prints correctly over multiple pages

position_y
>> 1065.8267716535433
box.position_y + box.height
>> 1065.8267716535433
@liZe liZe closed this as completed in 40d8394 Mar 18, 2024
@liZe
Copy link
Member

liZe commented Mar 18, 2024

Hi!

Thanks for reporting this issue. A lot of rounding errors have been fixed in the past to detect overflow on pages, that’s another case we have to handle.

@liZe liZe added this to the 62.0 milestone Mar 18, 2024
@liZe liZe added the bug Existing features not working as expected label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing features not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants