Forum How do I...?

Absolute Position'ed Elements Spanning past first page

joelmeador
I think the answer is "it doesn't work that way", but how would I get more than one page of content to appear for the input file I've attached. In searching the forums I found a bunch of stuff from ~2008 saying having absolute-positioned elements able to go past the first page is on the roadmap, but I can't find anything about it there and it doesn't work any differently between Prince 11 and the latest build version.

Also attached is the output from print to pdf from firefox, which also is not correct, but at least closer to what I expect in the sense that the content flows onto a second page.
  1. absolute-ff.html.pdf24.8 kB
    firefox spits this out
  2. absolute.html3.2 kB
    just a sample
mikeday
Right, absolutely positioned blocks are not split across pages, although floats are.
joelmeador
Is it still a thing you're considering to add, or is that the way it will always be? Earlier conversations I read on the subject here on the forum made me think the former. I'm not bothered if that's just the way it will be. :)
mikeday
It's complicated! In general absolute positioning allows very awkward situations, like having a block at the end of the document that is positioned with "top: 0", should this move to the top of the current page, or the top of the first page? Sites designed for browser layout might expect the latter.

Your example positions one block at "top: 800px", but unless considerable care is taken that could end up being somewhere in the margin between two pages.

There are some more limited possibilities where people make the entire document absolutely positioned even when it doesn't really need to be, or put all of the document content inside an inline-block. Both of these will result in the entire document being constrained to one page, and we might be able to detect some of the more common cases and just treat them specially.
joelmeador
It's complicated! In general absolute positioning allows very awkward situations, like having a block at the end of the document that is positioned with "top: 0", should this move to the top of the current page, or the top of the first page? Sites designed for browser layout might expect the latter.


I think I would expect the latter, and certainly that is how browser print-to-pdf seems to behave. The behavior of absolute position'ing is always to the top of it's relative position'ed context, so it seems like that still holds true even in a print layout, right? It seems like if you needed page alignment, that would call for a prince-specific print media extension, or maybe use something from some of the proposed paged media w3 stuff I haven't seen.

Your example positions one block at "top: 800px", but unless considerable care is taken that could end up being somewhere in the margin between two pages.

I think that is pretty reasonable if there is not an option to page align things as you described.

Both of these will result in the entire document being constrained to one page

The number of support requests we get with this being the nature of the problem is like 30+%. I feel ya. 😸

Thanks for talking this through. I believe you have thought more deeply about this than I have, and absolute positioning has a lot of workarounds in the web today, like not using it.