Solved

Page Break inside the HTML table

Posted on 2001-08-25
10
2,140 Views
Last Modified: 2007-11-27
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
0
Comment
Question by:Thangs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 20

Expert Comment

by:Silvers5
ID: 6424538
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
 
LVL 2

Accepted Solution

by:
Deathwish earned 300 total points
ID: 6424597
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
 
LVL 2

Author Comment

by:Thangs
ID: 6427640
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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 2

Author Comment

by:Thangs
ID: 6427646
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
 
LVL 2

Expert Comment

by:Deathwish
ID: 6428101
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
 
LVL 2

Author Comment

by:Thangs
ID: 6428406
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
 
LVL 2

Expert Comment

by:Deathwish
ID: 6428512
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
 
LVL 6

Expert Comment

by:Jon_Raymond
ID: 6428987
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
 
LVL 33

Expert Comment

by:hongjun
ID: 8755389
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question