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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Print undisplayed pages

Status
Not open for further replies.

livezone

MIS
Jan 17, 2003
81
CA
Hi,

I have a page which shows the lists of all orders created during the day. If I click print(java script page.print) I will get whatever I see on the page.

But what I want to achive is to print the page having all orders (Page shown on the browser) plus also the order detail page of all the orders. How can achive this?

In other words, How can i programatically create a spool file and send it to printer without displaying all the information on the web.

Thanks
Shafiq
 
My first approach would be to put the data-you-don't-want loaded on your page, but in a DIV with class='printOnly'. Then, have two STYLE sections in your HEAD:
Code:
<style type='text/css' media='screen'>
.printOnly{
 display:none;
}
</style>

<style type='text/css' media='print'>
.printOnly{
 display:block;
}
</style>

This approach is good if you don't mind user's being able to check the page's source code and seeing the values they are about to print. Since they CAN print them, I imagine you wouldn't mind if they saw them.

Another approach would be to have the PRINT button call a JavaScript function that sets the contents of an invisible (width='0%') IFRAME to what you would like to see printed. On that document (the one that loads in the invisible IFRAME), set the BODY tag's ONLOAD event to onload='window.print();'. This should print out what is in the unseen window.

'hope that helps.

--Dave
 
If there are a lot of orders, loading all the details could slow your page down. You could put this in <HEAD> to point to a detailed view:
Code:
<link rel="alternate" media="print" href="detailsPage.aspx">
Or you could point to the same page, but include a flag that tells the server-side script to output the details as well.
Code:
<link rel="alternate" media="print" href="ordersPage.aspx?showDetails=true">

That way the details aren't sent to the client unless they decide to print.

Adam
 
Thanks Adam, You suggestions works ok. I just need some more information.

Header page is in ASPX file(Portrait) and my detail page is classic ASP file(Landscape). And also my detail file has a printing script which formats that page to landscape and remove the top and bottom links
Here is the scipts
<code>
function doprint() {
//save existing user's info
var h = factory.printing.header;
var f = factory.printing.footer;

//hide the button
document.all("printbtn").style.visibility = 'hidden';
//set header and footer to blank
factory.printing.header = "";
factory.printing.footer = "";
factory.printing.portrait=false;
factory.printing.leftMargin = 0.25;
factory.printing.topMargin = 0.25;
factory.printing.rightMargin = 0.25;
factory.printing.bottomMargin = 0.25;
//print page without prompt
factory.DoPrint(false);
//restore user's info
factory.printing.header = h;
factory.printing.footer = f;

//show the print button
document.all("printbtn").style.visibility = 'visible';
}
</code>

This scripts works when some some clicks on "PrintBtn". But when I put this code on body tag under onload="doprint()" for detail page. It only prints the detail page in Portrait mode and does not print the header page at all. Can you please guide?
 
Sorry Just one mistak in above. It only prints one page which is given inside

<link rel="alternate" media="print" href="detailsPage.aspx">
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top