/    Sign up×
Community /Pin to ProfileBookmark

Page break for printing

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

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@David_HarrisonDec 05.2003 — 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.
Copy linkTweet thisAlerts:
@shanuraguauthorDec 06.2003 — 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? :p ?
×

Success!

Help @shanuragu spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...