Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smart html page break

Tags:

html

css

I make html reports and print them (or PDF) and want to make smart page breaks. I want to avoid that the heading is on one page and the paragraph on the next page. In that case the next page should start with the heading.

I have tried page-break-after:avoid but with no success. And I don't understand why. If I try page-break-after:always it works. So I guess the avoid functions is not that good. I always use IE8.

Is their any script way to calculate where the page break should be? If their is I can just make a page-break-after:always at that place.

Thanks! /Georg

like image 200
ahrberg Avatar asked Nov 13 '22 13:11

ahrberg


1 Answers

This class is only a hint. A page break is only avoided if it can be avoided. If it would mean the result would have to be clipped, a page break will be inserted after all.

I don't think it's possible to calculate where the page breaks would be, because it depends on numerous variables, including printer margins and paper size, which are not accessable in CSS nor JavaScript.

like image 153
GolezTrol Avatar answered Dec 19 '22 01:12

GolezTrol