Important alert: (current site time 7/16/2013 12:01:39 AM EDT)
 

VB icon

How to add "Print" button to your page

Email
Submitted on: 6/16/2000 9:01:49 AM
By: Agnus Imonar  
Level: Beginner
User Rating: By 15 Users
Compatibility: ASP (Active Server Pages), HTML
Views: 77975
(About the author)
 
     Prints out the content of a webpage
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: How to add "Print" button to your page
' Description:Prints out the content of a webpage
' By: Agnus Imonar
'
' Returns:Hard copy of your page
'
' Assumes:Insert the code into the body of your page where you want it to appear
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=6231&lngWId=4'for details.'**************************************

<form>
<input type="button" value="Print" Onclick="print()" ;>
</form>


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

6/21/2000 2:55:18 PMChris Rose

i am very new to asp. if anyone has any tips email me:
chris_1024@hotmail.com
(If this comment was disrespectful, please report it.)

 
6/21/2000 2:55:47 PMChris Rose

btw useful code

(If this comment was disrespectful, please report it.)

 
6/26/2000 9:38:27 PMAndy Lui

The code can not work in IE4.0!
(If this comment was disrespectful, please report it.)

 
6/5/2001 3:43:20 AMJason Ow

Simple and useful
(If this comment was disrespectful, please report it.)

 
11/26/2001 9:44:22 AMDean

Is there any way to set the page size to landscape or change page border sizes?
(If this comment was disrespectful, please report it.)

 
2/26/2002 2:50:55 AMandri

add print button
(If this comment was disrespectful, please report it.)

 
5/16/2002 10:37:04 AMRam

Could you please help me in setting the
print orientation in the code? Thanks
in advance.
(If this comment was disrespectful, please report it.)

 
8/6/2002 5:44:42 AMRaz

Has any1 got any ideas of the code required to print landscape, if so please mail me, thanks in advance
(If this comment was disrespectful, please report it.)

 
8/28/2002 10:53:24 AMcealex@hotmail.com

very nice!,
well done !, eh eh eh ... .

(If this comment was disrespectful, please report it.)

 
12/23/2002 10:40:26 AM

DId you find a solution to printing landscape???
ryangill@crosslink.net

(If this comment was disrespectful, please report it.)

 
10/31/2003 6:47:24 AM

you cannot print landscape until you use some activeX
(If this comment was disrespectful, please report it.)

 
11/3/2003 2:17:05 AM

is there a way we can show the print dialog to the user so that user can select the printer and print the specific file?

(If this comment was disrespectful, please report it.)

 
12/11/2003 1:10:34 PM

is There a way to preset the number of copies required?
(If this comment was disrespectful, please report it.)

 
2/26/2004 7:08:12 AMTom Hayhold

Hey, is there any way to only print one cell in a table?
(If this comment was disrespectful, please report it.)

 
2/26/2004 7:08:16 AMTom Hayhold

Hey, is there any way to only print one cell in a table?
thanks
(If this comment was disrespectful, please report it.)

 
10/20/2004 3:04:09 AM

how can I capture printing date if I use this code?pleazee help mee
(If this comment was disrespectful, please report it.)

 
12/9/2004 9:13:34 PM

i new in database programming..so can somebody in planet source code recommend me the best article for newbies like me..thanks.
(If this comment was disrespectful, please report it.)

 
6/2/2005 9:43:47 AM

Here is how i set it to print landscape, its not the prettiest but it works well.
This is javascript with some activex.

var shell;
function SetPrintProperties() {
try {
shell = new ActiveXObject("WScript.Shell");

shell.SendKeys("%fu");
window.setTimeout("java script:SetPaperSize();",
1200);
window.setTimeout("javascript:setLandScape();", 2000);

} catch (e) {
alert('Please verify that your print settings have a Landscape orientation and minimum margins.');
}

}

function SetPaperSize() {
shell.sendKeys("%a{TAB}.2{TAB}0{TAB}0{TAB}0{ENTER}");
}
function setLandScape() {
shell.sendKeys("%fp");
window.print();

}


(If this comment was disrespectful, please report it.)

 
10/17/2006 3:30:16 PMTony

Thanks for sharing
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.