Web Print summary [zz 〕

Source: Internet
Author: User

1. http://csd.nenu.edu.cn/study/article.asp? Id = 300 & classid = 1
Print content such as the print button on the web page:

First, add the following content to the webpage:

<Object ID = "webbrowser" Height = "0" width = "0" classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2"
Viewastext>
</Object>

Then you can add the function buttons in sequence:

<Input onclick = "document. all. webbrowser. execwb (6, 1) "type =" button "value =" print "> <input onclick =" document. all. webbrowser. execwb (6, 6) "type =" button "value =" print ">
<Input onclick = "document. All. webbrowser. execwb (8, 1)" type = "button" value = "page settings">
<Input onclick = "document. all. webbrowser. execwb (7,1) "type =" button "value =" print preview "> & nbsp; <input type =" button "value =" Close Window "onclick =" javascript: window. close () ">

Put the two items in <center class = noprint> </center> and the buttons will not be printed. Of course we need to define noprint:

<Style media = "print">. noprint {display: None} </style> you only need to set the CSS Of the things you don't want to print to noprint.

Now we have implemented basic web printing. Note the following:

You must set the Security Settings of Internet Options of IE to prompt or enable ActiveX controls that are not marked as secure. Otherwise, an error will be reported, resulting in unavailability.
If you edit the page in the vs.net editing environment, it automatically adds additional parameters to the object. With these parameters, printing will fail, so remember to delete them when saving them.
To make it easy and achieve the best results, we can edit and print a page. At this time, a lot of textbox is required. We set its CSS to. edittext.
{
Overflow-Y: visible;
Width: 100%;
Border-top: none;
Border-Right: none;
Border-bottom: none;
Border-left: none;
.

There is also some small experience that when setting the width of the Standard grid, for A4 paper, horizontal use 920, vertical use 640, the best effect.

2.
Http://bbs.0415w.com/bbs/read.php? Tid = 311 & fpage = 5
First:
Good web printing: scriptx. Cab. With this, you can use JavaScript to print settings on the webpage.
Add in HTML head
<Object ID = "Factory" style = "display: none" codebase = "http://www.meadroid.com/scriptx/ScriptX.cab#Version=6,1,430,5"
Classid = "CLSID: 1663ed61-23eb-11d2-b92f-008048fdd814" viewastext>
</Object>
And write with Script
Sub setprint ()
Factory. Printing. header = "& W & B page & P, total & P page" '// set the text on the top
Factory. Printing. footer = "& D" '// set the text at the end of the page.
Factory. Printing. Portrait = true '// set it to print directly.
Factory. Printing. leftmargin = 0.1 '// set the Left Border
Factory. Printing. topmargin = 0.3 '// sets the upper boundary.
Factory. Printing. rightmargin = 0.1 '// sets the friend boundary.
Factory. Printing. bottommargin = 0.4 '// sets the bottom boundary.
Factory. Printing. Print (false) '// print it (true) to display the print query window. If it is false, the print query window is not displayed.
End sub
You only need to call the setprint sub to change the printing settings.
However, there are two restrictions: one is that the IE version is more than five, and the other is that the user must add the website to a fully trusted website for use. Otherwise, errors may occur.

Second:
<Script language = "JavaScript">
Function printsetup (){
// Print page settings
Wb.exe CWB (8, 1 );
}
Function printpreview (){
// Print the Page Preview
    
Wb.exe CWB (7,1 );
     
    
}

Function printit ()
{
If (confirm ('Are you sure you want to print? ')){
Wb.exe CWB (6, 6)
}
}
</SCRIPT>
</Head>
<Body>
<Object classid = "CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2"

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 = "disabled"

Onclick = "javascript: window. Close ();">

Third:
Use the filesystem component to implement specific local printing in Web Applications
<Script language = VBScript>
Function print_onclick // print the Function
Dim label
Label = Document. printinfo. Label. Value // obtain HTML page data
Set objfs = Createobject ("scripting. FileSystemObject") // create an instance of the filesystem Component Object
Set 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
Set objprinter = nothing
Set objfs = nothing // disable the filesystem Component Object
End Function
</SCRIPT>
Server 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:
<HTML>
.........
<Form ID = printinfo name = "printinfo">
<Input type = "button" value = "Print>" id = Print name = print> // call the print function
<Input type = hidden id = text1 name = label value = <% = ......... %> // Save data sent from the server
.........
</Html>

3 Floating frame Printing
<Script language = JavaScript>
Function button1_onclick (){
VaR odoc=w.w.iframe1.doc ument;
VaR r = odoc. Body. createTextRange ();
VaR stxt=r.html text;
Alert (stxt)
VaR pwin = Window. Open ("", "print ");
Pwin.doc ument. Write (stxt );
Pwin. Print ();
}
</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.