SoFunction
Updated on 2025-03-10

Asp Implementation of WEB Printing Code Complete

(1)<script defer> 
function SetPrintSettings() { 
 // -- advanced features 
 (2) // measure margins in inches 
 (false, 1, 3) // need pages from 1 to 3 
  = "HP DeskJet 870C" 
  = 2 
  = true 
  = "A4" 
  = "Manual feed" 

 // -- basic features 
  = "This is MeadCo" 
  = "Advanced Printing by ScriptX" 
  = false 
  = 1.0 
  = 1.0 
  = 1.0 
  = 1.0 

</script> 

(2) 
<script language="javascript"> 
function printsetup(){ 
// Print page settings
(8,1); 

function printpreview(){ 
//Print page preview
 
(7,1); 
  
 


function printit() 

if (confirm('Are you sure to print?')) {
(6,6) 


</script> 
</head> 
<body> 
<OBJECT class 

height=0 id=wb name=wb width=0></OBJECT> 
<input type=button name=button_print value="Print"

onclick="javascript:printit()"> 
<input type=button name=button_setup value="Print page settings"

onclick="javascript:printsetup();"> 
<input type=button name=button_show value="Print Preview"

onclick="javascript:printpreview();"> 
<input type=button name=button_fh value="Close"

onclick="javascript:();"> 

------------------------------------------------ 
There are other uses of this component, listed as follows:
(1,1) Open
(2,1) Close all IE windows now and open a new window
(4,1) Save the web page
(6,1) Print
(7,1) Print preview
(8,1) Print page settings
(10,1) View page properties
(15,1) It seems to be cancelled, and it is to be confirmed
(17,1) Select all
(22,1) Refresh
(45,1) Close the form without prompt

2. Pagination printing
<HTML> 
<HEAD> 
<STYLE> 
P {page-break-after: always} 
</STYLE> 
</HEAD> 
<BODY> 
<%while not %> 
<P><%=rs(0)%></P> 
<%%> 
<%wend%> 
</BODY> 
</HTML> 

3. How to remove the path at the bottom of the page and the page number at the top when printing ASP page
(1) IE's file -> Page settings -> Remove the header and footer in it, and it won't be printed out.
(2)<HTML> 
<HEAD> 
<TITLE> New Document </TITLE> 
<META NAME="Generator" CONTENT="EditPlus"> 
<META NAME="Author" CONTENT="YC"> 
<script language="VBScript"> 
dim hkey_root,hkey_path,hkey_key 
hkey_root="HKEY_CURRENT_USER" 
hkey_path="\Software\Microsoft\Internet Explorer\PageSetup" 
'//Set the header and footer of the web page printing to be empty
function pagesetup_null() 
on error resume next 
Set RegWsh = CreateObject("") 
hkey_key="\header" 
 hkey_root+hkey_path+hkey_key,"" 
hkey_key="\footer" 
 hkey_root+hkey_path+hkey_key,"" 
end function 
'//Set the header and footer of web page printing as the default value
function pagesetup_default() 
on error resume next 
Set RegWsh = CreateObject("") 
hkey_key="\header" 
hkey_root+hkey_path+hkey_key,"&w&b page number,&p/&P"
hkey_key="\footer" 
 hkey_root+hkey_path+hkey_key,"&u&b&d" 
end function 
</script> 
</HEAD> 

<BODY> 
<br/> 
<br/> 
<br/> 
<br/> 
<br/> 
<br/><p align=center> 
<input type="button" value="Clear the page number" onclick=pagesetup_null()> <input type="button" value="Recover the page" onclick=pagesetup_default()><br/>

</p> 
</BODY> 
</HTML> 
4. Floating frame printing
<SCRIPT LANGUAGE=javascript> 
function button1_onclick() { 
var odoc=window.; 
var r=(); 
var stxt=; 
alert(stxt) 
var pwin=("","print"); 
(stxt); 
(); 

</SCRIPT> 
4. Use FileSystem component to implement local specific printing in WEB applications.
<script Language=VBScript> 
function print_onclick //Print function
dim label 
label=//Get data of HTML page
set objfs=CreateObject("") //Create an instance of the FileSystem component object
set objprinter= ("LPT1:",true) //Establish a connection with the printer
("_____________________________________") //Output the printed content
("| |") 
("| The data you print is: "&label&" |)
("| |") 
("|_________________________________|") 
//Disconnect the printer
set objprinter=nothing 
set objfs=nothing // Close the FileSystem component object
end function 
</script> 
Server-side script:
<%……… 
set conn= ("") 
 "DSN=name;UID=XXXX;PWD=XXXX;" 
set rs=("") 
(“select ……”),conn,1,1 
………….%> //Interact with the database
HTML page encoding:
<HTML> 
……… 
<FORM ID=printinfo NAME="printinfo" > 
<INPUT type="button" value="Print>>" id=print name=print > //Calling the print function
<INPUT type=hidden id=text1 name=label value=<%=………%>> //Save data transmitted from the server
……… 
</HTML>