Jump to content

page-break problems


GernotM
 Share

Recommended Posts

I have an asp program that prints a variable-length html table extending over several pages. I don't want table rows broken between pages. Adding the "page-break-inside:avoid" style to <tr> should accomplish this but it does not work in IE8.As a workaround I can add the "page-break-before:always" (or "page-break-after:always") style to the appropriate <tr> but the <tr> at which this has to be inserted depends on many factors of table layout and in practice requires a test print to find the right <tr> (and the hope that nothing in the layout changes). Until "page-break-inside:avoid" is fixed, is there a way other than trial-and-error to find/compute the <tr> at which a page break is forced? Thanks,GernotM

Link to comment
Share on other sites

I maligned IE8 wrongly. After googling some more I foundmsdn.microsoft.com/en-us/library/cc304067(v=vs.85).aspxwhich shows how to make page-break-inside:avoid work in IE8. The working asp program is shown here (Note the <meta ..> tag):<html><head><meta http-equiv="X-UA-Compatible" content="IE=8" /><style type="text/css">@media print { tr { page-break-inside: avoid; }}</style><title>PrintTest</title></head><body onload="window.print()"> <table align="center" border="1" style="font:51pt Verdana"> <tr><th colspan="2">51 pt</th></tr> <% for i = 0 to 12 %> <tr><td align="center"><%=i%></td></tr> <% next %> </table> </body></html>The only complaint is that if you collapse the table borders then the top cell on page 2 will have no top border. This is minor, but the top border appears when the break is forced with page-break-before.Thanks,Gernot Metze

Link to comment
Share on other sites

I maligned IE8 wrongly. After googling some more I foundmsdn.microsoft.com/en-us/library/cc304067(v=vs.85).aspxwhich shows how to make page-break-inside:avoid work in IE8. The working asp program is shown here (Note the <meta ..> tag):<html><head><meta http-equiv="X-UA-Compatible" content="IE=8" /><style type="text/css">@media print { tr { page-break-inside: avoid; }}</style><title>PrintTest</title></head><body onload="window.print()"> <table align="center" border="1" style="font:51pt Verdana"> <tr><th colspan="2">51 pt</th></tr> <% for i = 0 to 12 %> <tr><td align="center"><%=i%></td></tr> <% next %> </table> </body></html>The only complaint is that if you collapse the table borders then the top cell on page 2 will have no top border. This is minor, but the top border appears when the break is forced with page-break-before.Thanks,Gernot Metze

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...