Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Problems

Status
Not open for further replies.

Mighty

Programmer
Feb 22, 2001
1,682
US
I have two divs on my a page - one represents the screen view and one is the printview. I then use CSS to display the screen view to the user but to print the "print view" when the user clicks on the print button.

I use this method on several different pages. However, a common trend is that a blank page tends to print out at the end of the content of the print div. Any ideas why this would happen. It happens in several different programs so I am not sure why.

Also in older versions of IE it even tries to print thousands of pages even though there might be only one page of data. Any insights into this would be appreciated.

Mighty
 
Mighty,

If you set the DIV you DON'T want printed to visibility='hidden', make sure to also set display='none'.

An invisible item still takes up space on the page unless the display style element is set to 'none'.

'hope this helps.

--Dave
 
Dan,

In an external style sheet file, I have the following:

@media print {
#screenView {display: none;}
#printView {display: block;}
#menu0item1 {display: none;}
#menu0item2 {display: none;}
#menu0item3 {display: none;}
#menu0item4 {display: none;}
#menu0item5 {display: none;}
#menu0item6 {display: none;}
#menu0item7 {display: none;}
#menu0item8 {display: none;}
#menu0item9 {display: none;}
#menu0item10 {display: none;}
}

@media screen {
#screenView {display: block;}
#printView {display: none;}
}


Then in my code I simply have something like the following:

<HTML>
<HEAD>
<LINK REL=stylesheet HREF="........>
</HEAD>
<BODY>
<DIV ID="screenView">

Screen view content goes in here

</DIV>
<DIV ID="printView">

Stuff to be printed goes here

</DIV>
</BODY>
</HTML>


Any ideas on this??

Mighty
 
Try breaking your CSS down into to separate style sheets, and including them with the media specified on the page:

Code:
<link rel="stylesheet" type="text/css" media="screen" href="myScreenCSS.css">
<link rel="stylesheet" type="text/css" media="print" href="myPrintCSS.css">

Apart from that, i can't suggest much!

Hope this helps,
Dan
 
The supplied code works as expected on my IE6, Mozilla 1.5 and Opera 7.23. No blank pages were printed.
 
Well, the actual code would be something like below. There are several images and a naviagation scripts that runs on page load. But you'll get the idea:



<HTML>
<HEAD>
<TITLE>Carmed Technologies</TITLE>
<META NAME="generator" CONTENT="Sausage Software HotDog Professional 6">
<META NAME="author" CONTENT="Nick Elliott">
<LINK REL=stylesheet HREF="/styles/csprint.css" TYPE="text/css">
<SCRIPT LANGUAGE="JavaScript" SRC="/scripts/local/intranet.js"></SCRIPT>
</HEAD>
<BODY onLoad="writeMenus();help='invce1'">
<DIV ID="screenView">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR="#3F67AF" WIDTH=100% FRAME="void" rules="all" height="100%">
<TR>
<TD WIDTH=30 rowspan=2 valign=center><IMG SRC="/images/misc/empty.gif" width="30"></TD>
<TD COLSPAN=2 valign=bottom height=112>&nbsp;&nbsp;<IMG SRC="/images/misc/logoblue.gif" WIDTH="650" HEIGHT="112" ALIGN="Bottom" BORDER="0" ALT="Carmed Logo"></FONT>
</TD>
</TR>
<TR>
<TD HEIGHT="54" valign=top><IMG SRC="/images/misc/factory.jpg" WIDTH="147" HEIGHT="54" BORDER="0" ALT="Carmed Factory"></TD>
<TD width=90%><TABLE BORDER=0 HEIGHT=54 CELLPADDING=0 CELLSPACING=0><TR><TD><FONT FACE="ARIAL" SIZE="-1" COLOR="#A0B0CF">&nbsp;<a HREF="/intranet">Carmed Intranet</A> » <a HREF="/intranet/sc">Supply Chain</A> » Print Invoice</FONT></TD></TR><TR><TD><table bgcolor="WHITE" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td height="17" align=center></td></tr></table></TD></TR></TABLE></TD>
</TR>

<TR>
<TD WIDTH=30>&nbsp;</TD>
<TD COLSPAN=2 valign="top" height="100%">

<TABLE BORDER=0>
<TR>
<TD><IMG SRC="/images/misc/empty.gif" width="5"></TD>
<TD>

<BR>
<H1>Print Invoices</H1>
<P>The invoices that you selected have been prepared for printing. Please click on the Print button below to
send the invoices to the printer. Please be sure to specify if you need to print more than one copy.</P>

<P STYLE="margin-left: 20;"><IMG SRC="/images/misc/print.gif" onClick="window.print();" STYLE="cursor: hand;"></P>

<P>Click <A HREF="CSInvoicePrint.asp">here</A> if you wish to print other invoices</P>

</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD WIDTH=30>&nbsp;</TD>
<TD COLSPAN=2 ALIGN=CENTER STYLE="font: 10pt Verdana; font-weight: bold">&nbsp;&nbsp;<A HREF="/intranet" onMouseOver="self.status='Carmed Intranet Home'; return true;" onMouseOut="self.status=''">Home</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/Sales" onMouseOver="self.status='Sales/Customer Service Section'; return true;" onMouseOut="self.status=''">Sales/CS</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/Engineering" onMouseOver="self.status='Engineering Section'; return true;" onMouseOut="self.status=''">Engineering</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/Balloons" onMouseOver="self.status='Balloon Data Entry'; return true;" onMouseOut="self.status=''">Balloon Data</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/QA" onMouseOver="self.status='Complaints Administration'; return true;" onMouseOut="self.status=''">QA</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/finance" onMouseOver="self.status='Finance Section'; return true;" onMouseOut="self.status=''">Finance</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/IT" onMouseOver="self.status='IT Section'; return true;" onMouseOut="self.status=''" onClick="return true">IT</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/measures" onMouseOver="self.status='Measures Reports'; return true;" onMouseOut="self.status=''" onClick="return true;">Measures</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/Feedback.asp" onMouseOver="self.status='Enter requests for updates/modification to the Carmed Intranet'; return true;" onMouseOut="self.status=''">Feedback</A>&nbsp;&nbsp;&nbsp;&nbsp;<A HREF="/intranet/index.asp?logout" onMouseOver="self.status='Logout from the Carmed Intranet'; return true;" onMouseOut="self.status=''">Logout</A></TD>
</TR>
</TABLE>
</DIV>
<DIV ID="printView">

<TABLE BORDER=0 Align=CENTER STYLE="font-family: Arial, helvetica, Sans-Serif; Font-size: 10pt">


<TR>
<TD>
<TABLE WIDTH="640" BORDER="0" ALIGN="CENTER" STYLE="font-family: Arial, helvetica, Sans-Serif; Font-size: 10pt">
<TR>
<TD WIDTH="34%" ALIGN="CENTER" valign=top>
<IMG SRC="/images/banner/logoSmall.gif" vspace=0 hspace=0 align=abstop>
<FONT SIZE="-2">My Street, My Town<BR>My County, My Country.<BR>
Tel:&nbsp;123-45-67890&nbsp;&nbsp;Fax:&nbsp; 123-45-67890<BR>Email:&nbsp;info@Carmed.ie<BR>
Web:&nbsp; </TD>
<TD WIDTH="32%" ALIGN="CENTER" VALIGN="CENTER">
<IMG SRC="/images/misc/sgs9001.jpg">&nbsp;&nbsp;&nbsp;&nbsp;<IMG SRC="/images/misc/sgs13485.jpg">
</TD>
<TD WIDTH="34%" ALIGN="CENTER" VALIGN="CENTER">
<TABLE CELLPADDING=3 CELLSPACING=0 STYLE="font-family: Arial, helvetica, Sans-Serif; Font-size: 9pt" BORDER=1 BORDERCOLOR=#000000 WIDTH=200>
<CAPTION STYLE="font-family: Verdana; font-size: 10pt"><B>INVOICE</B></CAPTION>
<TR>
<TH>NUMBER</TH><TH>DATE</TH><TH>PAGE</TH>
</TR>
<TR>
<TD ALIGN="CENTER" VALIGN="CENTER">008868</TD>
<TD ALIGN="CENTER">29-Apr-04</TD>
<TD ALIGN="CENTER">1 of 1</TD>
</TR>
<TR>
<TH COLSPAN="3">CUSTOMER VAT NO.</TH>
</TR>
<TR>
<TD COLSPAN="3" ALIGN="CENTER">&nbsp;</TD>
</TR>
</TABLE>

</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD><BR>
<TABLE BORDER=0 WIDTH=600 STYLE="font-family: Arial, helvetica, Sans-Serif; Font-size: 10pt; margin-left: 20;">
<TR>
<TD VALIGN=TOP WIDTH=275><B>BILL TO:</B></FONT><BR>Customer Company,<BR>Accounts Payable Dept.,,<BR>Central Supplies Dept.,<BR>County<BR>Country.</TD>
<TD><IMG SRC="/images/misc/empty.gif" WIDTH="50"></TD>
<TD VALIGN=TOP WIDTH=275><B>SHIP TO:</B></FONT><BR>Customer Company,<BR>Central Supplies Department,,<BR>County,<BR>Country.</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER"><BR>
<TABLE WIDTH="640" CELLPADDING=3 CELLSPACING=0 STYLE="font-family: Arial, helvetica, Sans-Serif; Font-size: 9pt" BORDER=1 BORDERCOLOR=#000000>
<TR>
<TH>CUSTOMER PURCHASE ORDER NO.</TH>
<TH>TERMS</TH>
<TH>SHIP VIA</TH>
<TH>F.O.B. POINT</TH>
</TR>
<TR>
<TD ALIGN="CENTER">02/276532<BR></TD>
<TD ALIGN="CENTER">Nett 45 days</TD>
<TD ALIGN="CENTER">Interlink</TD>
<TD ALIGN="CENTER"><BR></TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<TABLE WIDTH="640" CELLPADDING=3 CELLSPACING=0 STYLE="font-family: Arial, helvetica, Sans-Serif; Font-size: 9pt" BORDER=1 BORDERCOLOR=#000000>
<TR>
<TH>ORDERED BY</TH>
<TH>SALES REPRESENTATIVE</TH>
<TH>ORDER DATE</TH>
<TH>OUR ORDER NO.</TH>
<TH>CUSTOMER ID.</TH>
</TR>
<TR>
<TD ALIGN="CENTER">Mary<BR></TD>
<TD ALIGN="CENTER">Joe Bloggs</TD>
<TD ALIGN="CENTER">28-Apr-04</TD>
<TD ALIGN="CENTER">222650</TD>
<TD ALIGN="CENTER">WRH</TD>
</TR>
</TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<TABLE WIDTH="640" CELLPADDING=3 CELLSPACING=0 STYLE="font-family: Arial, helvetica, Sans-Serif; Font-size: 8pt" BORDER=1 BORDERCOLOR=#000000>
<TR>
<TH ROWSPAN="2">LIN</TH>
<TH ROWSPAN="2">DL</TH>
<TH COLSPAN="2">QUANTITY</TH>
<TH ROWSPAN="2">PART NUMBER</TH>
<TH>DESCRIPTION</TH>
<TH ROWSPAN="2">UNIT</TH>
<TH ROWSPAN="2">UNIT PRICE</TH>
<TH ROWSPAN="2">EXTENDED PRICE</TH>
</TR>
<TR>
<TH>ORDERED</TH>
<TH>SHIPPED</TH>
<TH STYLE="color: red;">COMMENTS:</TH>
</TR>

<TR VALIGN=TOP>
<TD ALIGN="CENTER">01</TD>
<TD ALIGN="CENTER">01</TD>
<TD ALIGN="CENTER">2.00</TD>
<TD ALIGN="CENTER">2.00</TD>
<TD ALIGN="CENTER">28303058</TD>
<TD ALIGN="LEFT">
8X40X75 CLEAR PAC-XT<BR>
</TD>
<TD ALIGN="CENTER">EA</TD>
<TD ALIGN="CENTER">$150.00</TD>
<TD ALIGN="CENTER">300.00
</TD>
</TR>


<TR>
<TD ALIGN="LEFT" VALIGN="CENTER" COLSPAN="9">
<TABLE BORDER=0 CELLPADDING=3 CELLSPACING=0 STYLE="font: 7pt verdana">
<TR VALIGN=TOP>
<TD><B>Comment:</B></TD><TD>VAT @ 21%<BR></TD>
</TR>
</TABLE>
</TD>
</TR>

</TABLE>
</TD>
</TR>
<TR>
<TD ALIGN="CENTER">
<TABLE WIDTH="640" CELLPADDING=3 CELLSPACING=0 STYLE="font-family: Arial, helvetica, Sans-Serif; Font-size: 9pt" BORDER=1 BORDERCOLOR=#000000>
<TR>
<TH>LINE ITEM TOTALS</TH>
<TH>DISCOUNT</TH>
<TH>SUB TOTAL</TH>
<TH>SHIPPING & HANDLING</TH>
<TH>TAXABLE AMOUNT</TH>
<TH>TAX</TH>
<TH>MISC</TH>
<TH>INVOICE TOTAL</TH>
</TR>
<TR>

<TD ALIGN="CENTER">300.00</TD>
<TD ALIGN="CENTER">0</TD>
<TD ALIGN="CENTER">300.00</TD>
<TD ALIGN="CENTER">15.00</TD>
<TD ALIGN="CENTER">300.00</TD>
<TD ALIGN="CENTER">63.00</TD>
<TD ALIGN="CENTER">0.00</TD>
<TD ALIGN="CENTER">$378.00</TD>

</TR>
</TABLE>
</TD>
</TR>
</TABLE>


</DIV>
</BODY>
</HTML>



Mighty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top