ASP development essential: Web print code Daquan This article mainly introduces various printing effects of the ASP to control the Web, which can control vertical, horizontal, and page margins.
1. Control "vertical", "horizontal" and "margins of the page".
code:
Function setPrintSettings () {
// - Advanced Features
Factory.printing.setMarginMeasure (2) // Measure Margins in inches
Factory.SETPAGERANGE (False, 1, 3) // NEED PAGES from 1 to 3
Factory.printing.printer = "HP Deskjet 870c"
Factory.printing.copies = 2
Factory.printing.collate = TRUE
Factory.printing.Papersize = "a4"
Factory.printing.Papersource = "Manual feed"
// - Basic Features
Factory.printing.Header = "this is meadco"
Factory.printing.footer = "Advanced Printing By Scriptx"
Factory.printing.portrait = false
Factory.printing.LAFTMARGIN = 1.0
Factory.printing.topmargin = 1.0
Factory.printing.rightmargin = 1.0
Factory.printing.bottommargin = 1.0
}
script>
code:
Function printsetup () {
// Print page settings
Wb.execwb (8, 1);
}
Function printpreview () {
// Print page preview
Wb.execwb (7, 1);
}
Function printit ()
{
IF (confirm ('OK print?')) {
Wb.execwb (6,6)
}
}
script>
P {page-break-after: always}
Style>
HEAD>
<% While Not Rs.eof%>
<% = rs (0)%> p>
<% rs.movenext%>
<% wend%>
Body>
Html>
3, how to get off the path at the bottom of the page and the top page number number when printing
IE file -> page settings -> The things inside the header and footer are removed, and if you print, you can't come out.
code:
DIM HKEY_ROOT, HKEY_PATH, HKEY_KEY
HKEY_ROOT = "HKEY_CURRENT_USER"
HKEY_PATH = "/ Software / Microsoft / Internet Explorer / Pagesetup"
'// Set the page foot foot of the web page
Function Pagesetup_null ()
ON Error ResMe next
Set regwsh = creteObject ("wscript.shell")
HKEY_KEY = "/ header"
RegWsh.Regwrite HKEY_ROOT HKEY_PATH HKEY_KEY, ""
HKEY_KEY = "/ footer"
RegWsh.Regwrite HKEY_ROOT HKEY_PATH HKEY_KEY, ""
END FUNCTION
'// Set the page foot feet of the web page to default
Function Pagesetup_default ()
ON Error ResMe next
Set regwsh = creteObject ("wscript.shell")
HKEY_KEY = "/ header"
RegWsh.Regwrite HKEY_ROOT HKEY_PATH HKEY_KEY, "& W & W", & P / & P "HKEY_KEY =" / Footer "
RegWsh.Regwrite HKEY_ROOT HKEY_PATH HKEY_KEY, "& U & B & D"
END FUNCTION
script>
HEAD>
p>
Body>
Html>
4, floating frame printing
code:
Function button1_onclick () {
VAR ODOC = WINDOW.IFRAME1.DOCUMENT;
Var r = odoc.body.createtextRange ();
Var stxt = r.htmlText;
Alert (stxt)
VAR PWIN = WINDOW.OPEN ("", "print");
PWin.Document.write (stxt);
PWin.Print ();
}
Script>
4. Implement local specific print in web applications with FileSystem components
code:
Function print_onclick // Print function
Dim label
Label = Document.printinfo.Label.Value // Get data for the HTML page
Set objfs = createObject ("scripting.filesystemObject") / / Create an instance of a FileSystem component object
Set objprinter = objfs.createtextfile ("lpt1:", true) // Establish a connection with the printer
Objprinter.writeline ("________________________________________________") // Output Printing
Objprinter.writeline ("| |")
Objprinter.writeline ("| Your print data is:" & label & "|")
Objprinter.writeline ("| |")
Objprinter.writeline ("| _________________________________ |")
Objprinter.close // Disconnect from the printer
Set objprinter = Nothing
Set objfs = nothing // Turn the FileSystem component object
END FUNCTION
script>
Server-side script:
<% .........
Set conn = server.createObject ("adoDb.connection")
CONN.OPEN "DSN = Name; UID = xxxx; pwd = xxxx;"
SET RS = Server.createObject ("AdoDb.Recordset")
Rs.Open ("Select ..."), CONN, 1, 1
..........%> // interact with the database
HTML page encoding:
.........