Forums
This topic is locked
Making a long Recordset Printer Friendly?
Posted 07 Oct 2004 17:31:30
1
has voted
07 Oct 2004 17:31:30 Seb Adlington posted:
Hi,I'm trying to create a page that will print nicely formatted without arbitrary page breaks. I've found the PageBreak CSS command which works a treat but I need to tie it into a repeat region.
On average there are close to 100 records being displayed and I want to insert a pagebreak command every 30 records or so.
I know this should be some basic Javascript code to do this..?
Cheers
Seb
Replies
Replied 15 Oct 2004 15:49:44
15 Oct 2004 15:49:44 Vince Baker replied:
You could add a counter into the recordset repeat region that on reaching 30 writes a page break....
i.e.
Above your repeat region add this
<% dim strBRCounter
strBRCounter = 0
%>
Then, add the end of the repeat region (but inside it) add this
<%
strBRCounter = strBRCounter + 1
if strBRCounter = 30 then
VbCrLf 'This inserts a line feed, add another for two line feeds
strBRCounter = 0
end if
%>
That should work nicely.
Regards
Vince
DMX Talkzone Manager
Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)
VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting
i.e.
Above your repeat region add this
<% dim strBRCounter
strBRCounter = 0
%>
Then, add the end of the repeat region (but inside it) add this
<%
strBRCounter = strBRCounter + 1
if strBRCounter = 30 then
VbCrLf 'This inserts a line feed, add another for two line feeds
strBRCounter = 0
end if
%>
That should work nicely.
Regards
Vince
DMX Talkzone Manager
Visit my home: www.chez-vince.com
(Now completely CSS based and bye bye to all tables!)
VBScript | ASP | HTML | CSS | SQL | Oracle | Hosting
Replied 16 Oct 2004 01:54:41
16 Oct 2004 01:54:41 Seb Adlington replied:
Just the ticket, thankyou very much
Knew it should be fairly simple
Have had to adjust it to work with Javascript, but got the same effect.
Again many thanks
Seb
Knew it should be fairly simple
Have had to adjust it to work with Javascript, but got the same effect.
Again many thanks
Seb
Replied 29 Oct 2004 12:57:24
29 Oct 2004 12:57:24 Janusz Jasinski replied:
surely if you're using dreamweaver, you can just set it using the normal commands?
Yup - janusz.co.uk
Yup - janusz.co.uk
Replied 29 Oct 2004 13:17:37
29 Oct 2004 13:17:37 Seb Adlington replied:
Not Sure which Normal Dreamweaver Commands you mean there mate.
Always end up having to tweak javascript by hand.
If there's an easy way to produce similar code to below I'd love to know! Cheers
<%
sebcount = sebcount +1;
if (sebcount == 28) {
Response.Write('<P><DIV align="center" class="style15">Page: ' + page + ' of ' + totpages +'</DIV></P>') ;
Response.Write("<br class='newpage'>"
sebcount =0;
page = page +1;
Response.Write("<table width='725' border='1' align='center' cellpadding='0' cellspacing='1' bordercolor='#FFFFFF' bgcolor='#FFFFFF' ><tr bgcolor='#000000'><td width='349' height='20'><div align='center' class='style5 style14'><div align='center'>Product & Code </div></div></td><td width='40'><div align='center' class='style5 style14'><div align='center'>Pack</div> </div></td><td width='40'><div align='center' class='style5 style14'><div align='center'>Dept</div></div></td><td width='60'><div align='center' class='style5 style14'><div align='center'>Trade Price<br>Exc VAT</div></div></td><td width='40' class='style5 style14'><div align='center' class='style4'>Disc<BR> %</div></td><td width='60' class='style5 style14'><div align='center' class='style5 style14'>RRP</div></td><td width='60' class='style5 style14'><div align='center' class='style5 style14'>Sell Price<br>Inc VAT</div></td><td width='40' class='style5 style14'><div align='center' class='style5 style14'>GP<br>%</div></td><td width='36' class='style5 style14'><div align='center' class='style5 style14'>Qty</div></td>"
}
Repeat1__index++;
Recordset2.MoveNext();
if(Recordset2.EOF){
Response.Write('<P><DIV align="center" class="style15">Page: ' + page + ' of ' + totpages +'</DIV></P>') ;
}
}
%>
Always end up having to tweak javascript by hand.
If there's an easy way to produce similar code to below I'd love to know! Cheers
<%
sebcount = sebcount +1;
if (sebcount == 28) {
Response.Write('<P><DIV align="center" class="style15">Page: ' + page + ' of ' + totpages +'</DIV></P>') ;
Response.Write("<br class='newpage'>"
sebcount =0;
page = page +1;
Response.Write("<table width='725' border='1' align='center' cellpadding='0' cellspacing='1' bordercolor='#FFFFFF' bgcolor='#FFFFFF' ><tr bgcolor='#000000'><td width='349' height='20'><div align='center' class='style5 style14'><div align='center'>Product & Code </div></div></td><td width='40'><div align='center' class='style5 style14'><div align='center'>Pack</div> </div></td><td width='40'><div align='center' class='style5 style14'><div align='center'>Dept</div></div></td><td width='60'><div align='center' class='style5 style14'><div align='center'>Trade Price<br>Exc VAT</div></div></td><td width='40' class='style5 style14'><div align='center' class='style4'>Disc<BR> %</div></td><td width='60' class='style5 style14'><div align='center' class='style5 style14'>RRP</div></td><td width='60' class='style5 style14'><div align='center' class='style5 style14'>Sell Price<br>Inc VAT</div></td><td width='40' class='style5 style14'><div align='center' class='style5 style14'>GP<br>%</div></td><td width='36' class='style5 style14'><div align='center' class='style5 style14'>Qty</div></td>"
}
Repeat1__index++;
Recordset2.MoveNext();
if(Recordset2.EOF){
Response.Write('<P><DIV align="center" class="style15">Page: ' + page + ' of ' + totpages +'</DIV></P>') ;
}
}
%>
Replied 29 Oct 2004 13:23:19
29 Oct 2004 13:23:19 Seb Adlington replied:
Forgot to mention the whole point of the exercise, sorry.
The pages are to be printed out without any user intervention
Following code stuck in the bottom
<SCRIPT LANGUAGE="JavaScript">
window.print();
setTimeout("window.navigate('../suppliers/supplier_list.asp')",1000);
</script>
Cheers
The pages are to be printed out without any user intervention
Following code stuck in the bottom
<SCRIPT LANGUAGE="JavaScript">
window.print();
setTimeout("window.navigate('../suppliers/supplier_list.asp')",1000);
</script>
Cheers
Replied 29 Oct 2004 13:37:33
29 Oct 2004 13:37:33 Janusz Jasinski replied:
In dreamweaver you can specify how many records are being displayed.... instead of saying 'ALL' you can specify how many at any 1 time.
Then you create a recordset navigation where u can navigate: start, backward, forward. end or choose a range...
Yup - janusz.co.uk
edit - forgot to say that no javascript is involved!
Edited by - pee2pee on 29 Oct 2004 13:38:54
Then you create a recordset navigation where u can navigate: start, backward, forward. end or choose a range...
Yup - janusz.co.uk
edit - forgot to say that no javascript is involved!
Edited by - pee2pee on 29 Oct 2004 13:38:54
Replied 29 Oct 2004 14:13:51
29 Oct 2004 14:13:51 Seb Adlington replied:
Works ok when you want xx records per page - but I need to display all records on 1 long long page but then broken into groups of 30 with a pagebreak so that when printed, the browser won't just cut records in half. The DMX repeat region commands work great for screen display but can't handle (as far as I know) doing this..
Replied 29 Oct 2004 14:19:26
29 Oct 2004 14:19:26 Janusz Jasinski replied:
Replied 01 Nov 2004 11:47:48
01 Nov 2004 11:47:48 Lee Diggins replied:
Hi Seb
Try utlising the CSS property - page-break-after or page-break-before, providing the browser is CSS compliant this should work.
Digga
Sharing Knowledge Saves Valuable Time!!!
Try utlising the CSS property - page-break-after or page-break-before, providing the browser is CSS compliant this should work.
Digga
Sharing Knowledge Saves Valuable Time!!!
Replied 02 Nov 2004 00:30:21
02 Nov 2004 00:30:21 Seb Adlington replied:
Cheers,
Found it after some scouting the net - ended up including this in the header
<STYLE type="text/css" media="print">
<!--
br.newpage{page-break-before:always;}
-->
</STYLE>
then calling it from the repeat region on the page with
Response.Write("<br class='newpage'>"
Does the job nicely and I don't need to worry about browser versions as this is going to be a private system for about 20ish users and i have to givem all training..
Anyone know if you can embed page setup info such as margins or paper size, would be handy but isn't vital
Cheers for the info people
Found it after some scouting the net - ended up including this in the header
<STYLE type="text/css" media="print">
<!--
br.newpage{page-break-before:always;}
-->
</STYLE>
then calling it from the repeat region on the page with
Response.Write("<br class='newpage'>"
Does the job nicely and I don't need to worry about browser versions as this is going to be a private system for about 20ish users and i have to givem all training..
Anyone know if you can embed page setup info such as margins or paper size, would be handy but isn't vital
Cheers for the info people
Replied 02 Nov 2004 11:27:25
02 Nov 2004 11:27:25 Lee Diggins replied:
The only way I know how to do this is with IE print templates. As i've not done this myself, I can't give you any tips, but, if you do complete this, any chance you can post back how you did it.
Digga
Sharing Knowledge Saves Valuable Time!!!
Digga
Sharing Knowledge Saves Valuable Time!!!
Replied 02 Nov 2004 14:41:03
02 Nov 2004 14:41:03 Seb Adlington replied:
Nice one Digga,
wasn't easy but got it working using Print Templates see link at bottom for a full tutorial.
First off you need this header info
<html XMLNS<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>E>
<head>
<?IMPORT NAMESPACE="IE" IMPLEMENTATION="#default">
<title> ..... blah blah
then create a style
<STYLE TYPE="text/css">
.masterstyle
{
width:8.5in;
height:11in;
background:#FFFFFF;
margin:2px;
}
</STYLE>
height and width being the paper size
then in your page you define the seperate pages to be printed (gets rid of the need for page-break-before)
<IEEVICERECT ID="page1" CLASS="masterstyle" MEDIA="print">
info for page 1
</IEEVICERECT>
<IEEVICERECT ID="page2" CLASS="masterstyle" MEDIA="print">
info for page 2
</IEEVICERECT>
Managed to tie this in with the repeat region on my page and all up and running!
Some Links:
Tutorial: www.webreference.com/js/column89/index.html
MS info: msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/printpreview/reference/reference.asp
I also spent a few hours looking into TEMPLATEPRINTER which lets you play with the page setup info - was trying to get 2 copies printed by default - but this doesn't look too well supported yet and I think you have to call it from C++ gave up on that but if anyone knows an easy way to implement it - woud be handy then you could set copies/collate etc but also pick default printers and hide the print dialog box.
If you want a full copy of the code I managed to get working, let me know
Cheers
wasn't easy but got it working using Print Templates see link at bottom for a full tutorial.
First off you need this header info
<html XMLNS<img src=../images/dmxzone/forum/icon_smile_blush.gif border=0 align=middle>E>
<head>
<?IMPORT NAMESPACE="IE" IMPLEMENTATION="#default">
<title> ..... blah blah
then create a style
<STYLE TYPE="text/css">
.masterstyle
{
width:8.5in;
height:11in;
background:#FFFFFF;
margin:2px;
}
</STYLE>
height and width being the paper size
then in your page you define the seperate pages to be printed (gets rid of the need for page-break-before)
<IEEVICERECT ID="page1" CLASS="masterstyle" MEDIA="print">
info for page 1
</IEEVICERECT>
<IEEVICERECT ID="page2" CLASS="masterstyle" MEDIA="print">
info for page 2
</IEEVICERECT>
Managed to tie this in with the repeat region on my page and all up and running!
Some Links:
Tutorial: www.webreference.com/js/column89/index.html
MS info: msdn.microsoft.com/library/default.asp?url=/workshop/browser/hosting/printpreview/reference/reference.asp
I also spent a few hours looking into TEMPLATEPRINTER which lets you play with the page setup info - was trying to get 2 copies printed by default - but this doesn't look too well supported yet and I think you have to call it from C++ gave up on that but if anyone knows an easy way to implement it - woud be handy then you could set copies/collate etc but also pick default printers and hide the print dialog box.
If you want a full copy of the code I managed to get working, let me know
Cheers
Replied 02 Nov 2004 15:22:52
02 Nov 2004 15:22:52 Lee Diggins replied:
Hey Seb
Glad to see you got result and thanks for posting the print template code <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Digga
Sharing Knowledge Saves Valuable Time!!!
Glad to see you got result and thanks for posting the print template code <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Digga
Sharing Knowledge Saves Valuable Time!!!
Replied 02 Nov 2004 19:01:59
02 Nov 2004 19:01:59 Peutch Bly replied:
Don't know what kind of "records" you want to display, but if you use a table, you don't need css or asp or javascript (<img src=../images/dmxzone/forum/icon_smile_dissapprove.gif border=0 align=middle> or whatever, just good ol' HTML.
See part entitled "Headers, footers and the quest for the scrolling table" at : www.htmldog.com/guides/htmladvanced/tables/
<thead> and <tfoot> tags are designed so that when printing, there are displayed on each page.
See part entitled "Headers, footers and the quest for the scrolling table" at : www.htmldog.com/guides/htmladvanced/tables/
<thead> and <tfoot> tags are designed so that when printing, there are displayed on each page.
Replied 03 Nov 2004 00:00:17
03 Nov 2004 00:00:17 Seb Adlington replied:
Looks interesting - few tags in there i never seen before.
Must admit when I got to the bottom of the page and read this
"Note: Back to normal browser differences, this time IE doesn't have a clue when it comes to headers and footers, and although it renders them in the table, they will not appear at the top and bottom of every printed page, let alone deliver the scrolling table."
this put me off somewhat, all the clients that will be using my sytem will be on IE5.5 + !
Will have a scout through though, cheers for the info <img src=../images/dmxzone/forum/icon_smile_cool.gif border=0 align=middle>
Must admit when I got to the bottom of the page and read this
"Note: Back to normal browser differences, this time IE doesn't have a clue when it comes to headers and footers, and although it renders them in the table, they will not appear at the top and bottom of every printed page, let alone deliver the scrolling table."
this put me off somewhat, all the clients that will be using my sytem will be on IE5.5 + !
Will have a scout through though, cheers for the info <img src=../images/dmxzone/forum/icon_smile_cool.gif border=0 align=middle>