Solved

Page Break inside the HTML table

Posted on 2001-08-25
10
2,125 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
10 Comments
 
LVL 20

Expert Comment

by:Silvers5
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 2

Author Comment

by:Thangs
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:Deathwish
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
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 tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now