Page Break inside the HTML table

I was wondering if anyone knows how to insert a page break into a HTML table so that i can control what the print out of a table on my web site looks like.  I want the table to be one continuous table when viewed from the web browser (IE5.5) but i want to control what parts get printed on seperate pages.  Maybe the solution is to use a hidden character?  The main problem is that when my table is printed it will page break in the middle of a line of text.  Any help is greatly appreciated and thanks in advance.



I tried with page-break-inside: avoid etc. nothing seems to be working
LVL 2
ThangsAsked:
Who is Participating?
 
DeathwishConnect With a Mentor Commented:
I have have had to work with the same issue. The best way to do this though it will sound dumb is to simply have two copies of the table with one of them completely hidden via stylesheet classes. For example:

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>

<style>
@media screen {
.TableHideScreen {
display:none
}
}
@media print {
.TableHidePrinting {
display:none
}
}
</style>
<span Class="TableHidePrinting" id="viewonscreen">
<table id="viewonscreen">
<tr><td>data</td></tr>
<tr><td>data</td></tr>
<tr><td>data</td></tr>
<tr><td>data</td></tr>
<tr><td>data</td></tr>
</table>
</span>

<span Class="TableHideScreen" id="viewonprint">
<table >
<tr><td>data</td></tr>
<tr><td>data</td></tr>
</table>
<div style="page-break-before:always">
<table>
<tr><td>data</td></tr>
<tr><td>data</td></tr>
</table>
<div style="page-break-before:always">
<table>
<tr><td>data</td></tr>
<tr><td>data</td></tr>
</table>
</span>

</HTML>

Create this test page, then view it in IE 5.5. Go to print preview and you will see the results. On screen its one table, but printing it uses the second and should produce 3 pages.
0
 
Michel SakrCommented:
you can't do it effectively.. try to dump the data into a word doc using content type, but the client should have word installed on the machine :

<%
Response.ContentType = "application/doc.ms-word"
data here...
0
 
ThangsAuthor Commented:
DeathWish,
Your suggestion seems to be good if I know the contents of the HTML document already. But I am generating the HTML document dynamically, and the table can be any size. If I prefix the page breaks, then I may land in problems like overflowing of page while printing or more spacious in a page.

Any suggestion please.

For right answers I can award more points.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
ThangsAuthor Commented:
Hi,
STYLE = "page-break-inside: avoid" may solve my problem. But it doesn't seems to be working in IE5.5?. Any suggestion on this??
0
 
DeathwishCommented:
Just setup a counter and after so many lines insert a page break. You will have to play with it to see what the best number is. As for the "avoid" I have never heard of that. Here is some sample code.

<%
intPageBreakNum = 20 'Break each time at the 20th line.
i = 1

Set objRS = Server.CreateObject("ADODB.Recordset")
......rest of ado code here

%>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<TITLE></TITLE>
</HEAD>

<style>
@media screen {
.TableHideScreen {
display:none
}
}
@media print {
.TableHidePrinting {
display:none
}
}
</style>
<span Class="TableHidePrinting" id="viewonscreen">
<table id="viewonscreen">
<%
If Not objRS.EOF Then
Do While Not objRS
Response.Write "<TR><TD>" & objRS("FieldName") & "</TD></TR>" & vbCRLF
objRS.MoveNext
Loop
Else
%>
<TR><TD>No Records</TD>
<%
End If
%>
</table>
</span>

<span Class="TableHideScreen" id="viewonprint">
<table>
<%
If Not objRS.EOF Then
Do While Not objRS
Response.Write "<TR><TD>" & objRS("FieldName") & "</TD></TR>" & vbCRLF

If i = intPageBreakNum Then
Response.Write "</table><table>"
i = 1
End If

i = i + 1
objRS.MoveNext
Loop
Else
%>
<TR><TD>No Records</TD>
<%
End If
%>
</table></span>

</HTML>
0
 
ThangsAuthor Commented:
Hey,
The html file doesn't contain only the records, but lot of images, text and tables which will be created from VC++ program. The user will select various options to display /hide images/informations. I hope page-break-inside would help me. If you have any idea how to implement that stuff since IE5.5 is not supporting, that would be helpful.

Also, I am having a rough idea that we can use Print templates to do this. Any idea about this.
0
 
DeathwishCommented:
I am thinking a detail like the html being created from a C++ is kind of an important thing that should be mentioned in the beginning. Especially in sections like this which indicate its being done in ASP.

I still don't understand your problem here. Even if it originates from a C++ program you can still have some counter or indicator that after certain points or certain content. Just have the line

<div style="page-break-before:always"></div>

print out at certain points in your functions or routines. Ex. if you have a image that is 400 pixels high you can have before it this line because you know it could bleed onto the next page. Or if you have 20 rows of text you know on the 20th that next content needs to go to the next page. You can use if else statements to control the line appearing or not.

Let me end with this. This method is pretty much the only way in IE 5 to control printing unless you either write a custom control(which then requires people to install it and so on) or you use like what was suggested here and use a word document.
0
 
Jon_RaymondCommented:
You could use a COM object to create the HTML code.  You can determine where to place the page breaks by using a line counter as suggested.  For images you can track the height of the images and combine that with the line counter to determine the points at which to break.  Just use ASP to call up the CVOM object and write the HTML that was created there.
0
 
hongjunCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[points to Deathwish]

Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

hongjun
EE Cleanup Volunteer
0
All Courses

From novice to tech pro — start learning today.