Frage

I'm trying to figure out where a browser, specifically firefox or chrome, would insert page breaks when printing or print previewing an HTML document. For now I do not want to avoid the breaks, nor do I want to define where exactly to put a break. I'm aware of the page-break-* elements as defined in CSS 2.1 and CSS 3.0. I really want to figure out the last element on the current page and the first element on the next page and relate them to the actual HTML code.

As far as I know there are no events or signals I could register for. The next thing I thought of is to patch webkit or gecko and add a custom signal/event. But this is only possible, if the page break code is not scattered over too many files and members.

I'm not asking for a complete solution, rather any thoughts or hints how this could be accomplished at all.

Thanks in advance for any suggestions and ideas :)

UPDATE: I need to figure out the position of the page breaks programmatically as I want to modify and manipulate the original HTML file depending on the result.

War es hilfreich?

Lösung

What exactly are you trying to achieve? You can style pages according to page breaks and whether the page is being printed using only CSS with media queries.

If CSS is not enough for your use case and patching the renderer is a suitable solution: on Gecko, you can grep nsCSSFrameConstructor.cpp for calls to AddPageBreakItem, and then figure out where it's inserting the breaks. A paginated nsPresContext means this is a frame for printing or print-preview. Look for calls to nsPresContext::IsPaginated and nsPresContext::IsRootPaginatedDocument.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top