Solved

Page Break inside the HTML table

Posted on 2001-08-25
10
2,142 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
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!

 
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

635 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