Click to See Complete Forum and Search --> : Page break for printing


shanuragu
12-01-2003, 03:34 AM
Hi

I am displaying values in a table dynamically for printing.
How can I implement page breaker for the table??


<table id="tab1" width="99%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td width="24%" align="left"><font class="shnText"><b>Customer Name</b></font></td>
<td width="18%" align="left"><font class="shnText"><b>Invoice No</b></font></td>
<td width="14%" align="center"><font class="shnText"><b>Invoice Date</b></font></td>
<td width="14%" align="center"><font class="shnText"><b>Due Date</b></font></td>
<td width="12%" align="center"><font class="shnText"><b>Invoice Amount</b></font></td>
<td width="18%" align="center"><font class="shnText"><b>Total Amount</b></font></td>
</tr>
<%
If rsInvoices.RecordCount > 0 Then
Dim strOldMonth

strOldMonth = Month(rsInvoices("invoice_dt"))

While Not rsInvoices.Eof
lInvoiceAmt = Round(CDbl(rsInvoices("invoice_amt")) + CDbl(rsInvoices("tax_amt")))
lTotalOutstanding = lTotalOutstanding + lInvoiceAmt

If CInt(strOldMonth) <> CInt(Month(rsInvoices("invoice_dt"))) Then
strOldMonth = Month(rsInvoices("invoice_dt"))
%>
<tr>
<td width="85%" align="right" colspan="5"><font class="shnText"><b>MONTHLY TOTAL :</b></font></td>
<td width="15%" align="right"><font class="stepTextSmall"><b>Rs <%=objUtils.FormatString(CStr(lMonthTotal), "#,##,##0.00")%></b></font></td>
</tr>
<%
lMonthTotal = 0
End if
lMonthTotal = lMonthTotal + lInvoiceAmt
%>
<tr>
<td width="24%" align="left"><font class="shnTextSmall"><%=rsInvoices("user_nm")%></font></td>
<td width="18%" align="left"><font class="shnTextSmall"><%=Session("bill_prefix")%><%=objUtils.FormatString(CStr(rsInvoices("invoice_no")), "##0000")%></font></td>
<td width="14%" align="center"><font class="shnTextSmall"><%=objUtils.FormatString(CStr(rsInvoices("invoice_dt")), "mmm dd yyyy")%></font></td>
<td width="14%" align="center"><font class="shnTextSmall"><%=objUtils.FormatString(CStr(rsInvoices("due_dt")), "mmm dd yyyy")%></font></td>
<td width="12%" align="center"><font class="shnTextSmall">Rs <%=objUtils.FormatString(CStr(rsInvoices("invoice_amt")), "#,##0.00")%></font></td>
<td width="18%" align="center"><font class="shnTextSmall">Rs <%=objUtils.FormatString(CStr(lInvoiceAmt), "#,##,##0.00")%></font></td>
</tr>
<%
rsInvoices.MoveNext
Wend
%>


shara

David Harrison
12-05-2003, 05:17 PM
I don't know about paper sizes anywhere else, but in the UK A4 paper is the standard and is 210mm*297mm (21cm*29.7cm).

If you were to use CSS for the dimentions of the table you could have as many tables as you need with dimensions 19cm*27.7cm, that would allow a 1cm gap all round. Then do the same for your second table and third and fourth etc.

You would need more than one table to allow for the breaks in between. Also, if you are dynamically creating the content of the table, you would need to know the height of each cell in order to start a new table at the right distance down the page.

shanuragu
12-05-2003, 11:31 PM
No probs.. I manage to get through this problem. I would like to share the solution for the above problem with our Web developer Forum membrs for any future reference.

On my web page I am getting values dynamically. In this case all u have to do is just put the table in div tag/p tag & give resepective style sheet for page break (go through the dummy code given below).

<Style>
div { page-break-after: always }
</Style>


<body>
<%begin While Loop%>
<div>
<table>
</table>
</div>
<%End While Loop%>
</body>

I did struggle a bit to get the output, but it is too simple.
Hope this helps some one in future who come across the same problem what I had before.

Note: As long as the web page contents are aligned properly on the web page u need not have to worry about the table height/width. For printing just give window.print().

Shara:D :p :cool: