Web page Printing

Source: Internet
Author: User
I. page loading controls: < Object ID = "Factory" Style = "Display: none" Viewastext classid = "CLSID: 1663ed61-23eb-11d2-b92f-008048fdd814"
Codebase = "Http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360" > </ Object >

Control script: < Script defer >
Function Setprintsettings (){
// -- Advanced features, which has never been used, is to be confirmed.
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 used
Factory. Printing. Header =   " This is meadco "
Factory. Printing. footer =   " Advanced printing by scriptx "
Factory. Printing. Portrait =   False // Direction, true
Factory. Printing. leftmargin =   1.0
Factory. Printing. topmargin =   1.0
Factory. Printing. rightmargin =   1.0
Factory. Printing. bottommargin =   1.0  

Factory. Printing. Print ( False ) // Print directly, true, does not seem to work, always pop-up select printer window
Factory. Printing. pagesetup () // Print settings
Factory. Printing. Preview () // Print preview
}
< / SCRIPT>

Ii. page loading controls: <ObjectClassid= "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2"Height= 0ID= WBName= WBWidth= 0>
</Object>

Control script: < Script Language = " Javascript " >
Function Printsetup ()
{
// Print page settings
Wb.exe CWB ( 8 , 1 );
}
Function Printpreview ()
{
// Print Page Preview
Wb.exe CWB ( 7 , 1 );
}

FunctionPrintit ()
{
If(Confirm ('Are you sure you want to print it?'))
{
Wb.exe CWB (6,6)
}
}
</SCRIPT>

========================================================== ======================================
There are other usage examples of this component:
Webbrowser. execwb () Open
Web. execwb () Close all existing IE Windows and open a new window
Web. execwb () save Web Page
Web. execwb (6, 1) Printing
Web. execwb (7,1) print and preview
Web. execwb (8, 1) Printing page settings
Web. execwb () view page properties
Web. execwb () seems to be undo, to be confirmed
Select all web. execwb ()
Web. execwb (22, 1) Refresh
Web. execwb () Close form no prompt
3. modify registry settings to print IE
<Script language = "JavaScript">
VaR hkey_root, hkey_path, hkey_key

Hkey_root = "HKEY_CURRENT_USER"
Hkey_path = "" software "Microsoft" Internet Explorer "pagesetup" // ie prints the configured Registry address

// Set the modification function
Function pagesetup_null ()
{
VaR regwsh = Createobject ("wscript. Shell ")
Hkey_key = "" Header"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "// Header

Hkey_key = "" footer"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "" // footer

Hkey_key = "" margin_left"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "1" // key value setting -- left boundary

Hkey_key = "" margin_top"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "1" // key value setting -- upper boundary

Hkey_key = "" margin_right"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "1" // key value setting -- Right Border

hkey_key = "" margin_bottom "
regwsh. regwrite hkey_root + hkey_path + hkey_key, "1" // key value setting -- bottom boundary
}< br>
// Restore Default Settings
function pagesetup_default ()
{< br> var regwsh = Createobject ("wscript. shell ")

Hkey_key = "" Header"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "& W & B page, & P/& P" // page number-

Hkey_key = "" footer"
Regwsh. regwrite hkey_root + hkey_path + hkey_key, "& U & B & D" // URL, date, and other information
}
</SCRIPT>
4. Use the filesystem component to implement specific local printing in Web Applications
<Script language = JavaScript>
Function print_onclick () // print the Function
{
VaR label
Label = Document. printinfo. Label. Value // obtain HTML page data
VaR objfs = Createobject ("scripting. FileSystemObject") // create an instance of the filesystem Component Object
VaR objprinter = objfs. createtextfile ("LPT1:", true) // establish a connection with the printer
Objprinter. writeline ("__________________________________") // output printed content
Objprinter. writeline ("| ")
Objprinter. writeline ("| the data you printed is:" & label & "| ")
Objprinter. writeline ("| ")
Objprinter. writeline ("| _________________________________ | ")
Objprinter. Close // disconnect from the printer
VaR objprinter = nothing
VaR objfs = nothing // close the filesystem Component Object
}
</SCRIPT>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.