Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

page-break-after

Status
Not open for further replies.

KevinFSI

Programmer
Nov 17, 2000
582
US
Is there any way to say I want a page-break-after the length of the page has exceeded a certain number of inches (or pixels, but would prefer inches?)

I need to vent something that I'm sure most of you can realte to. I have a report that consists of dozens of tables. The first request was to select an option that printed each table on a separate page. Not too hard, I just made the table tag look like this:
Code:
<TABLE STYLE=&quot;page-break-after:always;&quot;>
So that was good. Then he wants it to not cut table rows off in the middle since some of the tables take up two or three pages (but still give a page break at the end even if there is only one row that carried over to the next page.) There is a lot of text in some of the cells which makes some of the rows quite large. Now, how on earth am I supposed to tell my page to do a page break after each table, but not split TR's? Is there even a way at all?

Thanks for listening all! Kevin
slanek@ssd.fsi.com
 
check the standards for css. There is a page break solution there you can find it at the w3c.org site. It is pretty far down on the page just keep scrolling.

it breaks down like this:



Resource Index >> Source Code Resources

--------------------------------------------------------------------------------

CSS Page Break Example


CSS page breaks supported only by 4.x browsers

Example:


--------------------------------------------------------------------------------

This will print on Page 1

This will print on Page 2


--------------------------------------------------------------------------------

HTML:

<HTML>

<HEAD>

<TITLE>Page Break</TITLE>

<STYLE type=&quot;text/css&quot;>
<!--
.break {page-break-before: always}
-->
</STYLE>

<BODY>

<P><B>CSS page breaks supported only by 4.x browsers</B></P>

<P CLASS=&quot;break&quot;>This will print on Page 1</P>

<P CLASS=&quot;break&quot;>This will print on Page 2</P>

</BODY>

</HTML>

hope this helped

 
Hi,

have you found a solution to this since I am Having the same problem with my tables.


Thanks
 
Yeah, I ended up writing a little script that loops through each row in the table, counts each row height, adds that number to a total, then inserts a page break once the total reaches a certain amount.

Pretty simple concept, but a pain in my arse to develop. Kevin
slanek@ssd.fsi.com
 
Kevin,

I was going to suggest the same thing. I battled with that for a few weeks until I finally had to set a loop that counted the records and inserted the page breaks accordingly.

Just an FYI, page-break-after:always; is not honored by Netscape, but you probably already know that.

ToddWW
 
Yeah, sometimes that browser incompatability stuff really gets under my skin!!! Kevin
slanek@ssd.fsi.com
 
Kevin,

thanks for your quick answer.

In javascript, How do you add up each row height while the table is building up ?

By the way, I have seen that &quot;page-break-inside:avoid;&quot; in the <TR> tag which would do what we are looking for is only supported by opera 5.0 : funny, isn't it ?

Thanks

François
 
What a wonderful idea for a page break attribute. No wonder IE & NN haven't come on board with it.

I'll get you some code. Basically what you do is use the onbeforeprint event handler to call a function which adds the offsetHeight of each row to a total. Each time a row height is added, it checks to see if the total exceeds the max (I usually set the max to 600px.) Of course, I think offsetHeight is only recognized by IE. Kevin
slanek@ssd.fsi.com
 
Thanks again Kevin

The code would be welcome if you can.

Regards
blygman@hotmail.com

François
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top