Closed
Description
Floated elements that don't fit on the current page simply fall off the bottom, rather than being placed on the next page.
Here's a handy long list of floated elements to demonstrate the problem: http://www.stripey.com/demo/weasyprint/float_off_bottom.html
Look at it in Firefox and do ‘Print Preview’. You should see that there's a page break, with the list being continued on page 2. Similarly if you print from Chromium.
But WeasyPrint generates this file, where the elements simply run off the bottom of the first page: http://www.stripey.com/demo/weasyprint/float_off_bottom.pdf
Activity
SimonSapin commentedon Feb 14, 2013
Yes, this is a known limitation: no page breaks are supported inside floats, absolute positioning, or table cells. Unfortunately right now I don’t have a better answer than “avoid using floats that way”.
I’d be happy to help anyone who wants to fix this, but this is a non-trivial change in the layout code. Otherwise this is something to be fixed eventually, but I don’t know when I’ll get to it.
Smylers commentedon Feb 14, 2013
Thanks. From your description I'm not sure whether this is the known limitation or not.
In this case I'm not trying to have page breaks inside a floated element, but between floated elements. Each
li
is floated separately. My apologies for not making that clearer in the initial report.[-]Floats fall off bottom of page[/-][+]Allow page breaks in floats, absolute blocks, inline-blocks, table-cells[/+]inline-block
elements taller than page get clipped #164liZe commentedon Oct 28, 2016
As reported in #375, we have the same problem with consecutive absolute/relative blocks.
hughsw commentedon Apr 27, 2017
I have just started using WeasyPrint, and I'm already a big fan. However, I have also quickly run into the float/break issue -- my users want Bootstrap and floated columns, and don't like what happens in the PDF document!
Can @SimonSapin or anyone else comment on the refactoring that would be necessary to fix this wartish problem? I haven't perused your codebase yet, but I know Python very well; so, I'm looking for high-level overview of the current layout model/algorithm and why it gets tripped up trying to put breaks in floats, and what would have to be changed.
Thanks,
-Hugh
SimonSapin commentedon Apr 27, 2017
301 @liZe
84 remaining items