Web Printing:
1. can meet the general printing conditions:
Use document. All. webbrowser. execwb (); to print the entire page
First, a simple and practical method (you can print multiple pages, control pages, and hide non-print items) is provided)
<! -- Save language independence as. html -->
<HTML>
<Head>
<Title> Report </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<! -- Media = print this attribute can be valid during printing -->
<Style media = print>
. Noprint {display: None ;}<! -- Hide non-print items when printing with this style -->
. Pagenext {page-break-after: Always ;}<! -- Control pagination -->
</Style>
<Style>
. Style_td
{
Border-bottom: 1 solid #000000;
Border-left: 1 solid #000000;
Border-Right: 0 solid # ffffff;
Border-top: 0 solid # ffffff;
}
. Style_tab
{
Border-color: #000000 #000000 #000000 #000000;
Border-style: solid;
Border-top-width: 2px;
Border-right-width: 2px;
Border-bottom-width: 1px;
Border-left-width: 1px;
}
. Noprint {
Font-family: "";
Font-size: 9pt;
}
</Style>
</Head>
<Body>
<Center class = "noprint">
<P>
<Object ID = webbrowser classid = CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2 Height = 0 width = 0>
</Object>
<Input type = button value = print onclick = Document. All. webbrowser. execwb (6, 1)>
<Input type = button value = print onclick = Document. All. webbrowser. execwb (6, 6)>
<Input type = button value = page setting onclick = Document. All. webbrowser. execwb (8, 1)>
</P>
<P> <input type = button value = print preview onclick = Document. All. webbrowser. execwb (7,1)>
<Br/>
</P>
<HR Align = "center" width = "90%" size = "1" noshade>
</Center>
<Table width = "90%" border = "0" align = "center" cellpadding = "2" cellspacing = "0"
Class = "style_tab">
<Tr>
<TD colspan = "3" class = "style_td"> page 1 </TD>
</Tr>
<Tr>
<TD width = "29%" class = "style_td"> & nbsp; </TD>
<TD width = "28%" class = "style_td"> & nbsp; </TD>
<TD width = "43%" class = "style_td"> & nbsp; </TD>
</Tr>
<Tr>
<TD colspan = "3" class = "style_td"> & nbsp; </TD>
</Tr>
<Tr>
<TD colspan = "3" class = "style_td"> <Table width = "100%" border = "0" cellspacing = "0"
Cellpadding = "0">
<Tr>
<TD width = "50%" class = "style_td"> <p> reports like this </P>
<P> general requirements are sufficient. </P> </TD>
<TD> & nbsp; </TD>
</Tr>
</Table> </TD>
</Tr>
</Table>
<HR Align = "center" width = "90%" size = "1" noshade class = "noprint">
<! -- Pagination -->
<Div class = "pagenext"> </div>
<Table width = "90%" border = "0" align = "center" cellpadding = "2" cellspacing = "0"
Class = "style_tab">
<Tr>
<TD class = "style_td"> page 2nd </TD>
</Tr>
<Tr>
<TD class = "style_td"> the page is displayed. </TD>
</Tr>
<Tr>
<TD class = "style_td"> & nbsp; </TD>
</Tr>
<Tr>
<TD class = "style_td"> & nbsp; </TD>
</Tr>
<Tr>
<TD class = "style_td"> <Table width = "100%" border = "0" cellspacing = "0" cellpadding = "0">
<Tr>
<TD width = "50%" class = "style_td"> <p> reports like this </P>
<P> general requirements are sufficient. </P> </TD>
<TD> & nbsp; </TD>
</Tr>
</Table> </TD>
</Tr>
</Table>
</Body>
</Html>
<! --
The webbrowser control object. Any version above Win98 is available.
In fact, it works with "Paging style tables" and HTML tables for normal printing.
If you want to use it for non-Windows users.
Remove the following:
<Center class = "noprint">
<P>
<! -- The most important thing is this -->
<Object ID = webbrowser classid = CLSID: 8856f961-340a-11d0-a96b-00c04fd705a2 Height = 0 width = 0>
</Object>
<Input type = button value = print onclick = Document. All. webbrowser. execwb (6, 1)>
<Input type = button value = print onclick = Document. All. webbrowser. execwb (6, 6)>
<Input type = button value = page setting onclick = Document. All. webbrowser. execwb (8, 1)>
</P>
<P> <input type = button value = print preview onclick = Document. All. webbrowser. execwb (7,1)>
<Br/>
</P>
<HR Align = "center" width = "90%" size = "1" noshade>
</Center>
-->
2. Use the scriptx control to set printing
//////////////////////////////////////// //////////
// Scriptx Control
// Technical Documentation http://www.meadroid.com/scriptx/docs/printdoc.htm
//////////////////////////////////////// //////////
<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>
Usage Tutorial:
<SCRIPT defer>
Function setprintsettings (){
// -- Advanced features, which has never been used and is awaiting confirmation.
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, it does not seem to work, always pop up the select printer window
Factory. Printing. pagesetup () // print settings
Factory. Printing. Preview () // print preview
}
</SCRIPT>
Save the following example scriptx. cab to the server
Add the following scriptx elements to the. aspx webpage.
<Object ID = factory style = "display: none"
Classid = "CLSID: 1663ed61-23eb-11d2-b92f-008048fdd814"
Codebase = "http: // [your path here]/scriptx. Cab # version = 6, 1, 432,1">
</Object>
[Your path here] as the server name or IP address and the path to the scriptx. Cab
Setting the printing format:
<SCRIPT>
Function printwindow (){
Factory. Printing. header = "this is meadco"; 'beginning
Factory. Printing. footer = "printing by scriptx"; 'Tail
Factory. Printing. Portrait = false; 'watermark
Factory. Printing. leftmargin = 1.0;
Factory. Printing. topmargin = 1.0;
Factory. Printing. rightmargin = 1.0;
Factory. Printing. bottommargin = 1.0;
Factory. Printing. Print (false );
}
</SCRIPT>
Design printing based on two rows:
<Input type = "button" name = "print" value = "print" onclick = "printwindow (''); ">
//////////////////////////////////////// ////////////
The scriptx. cab file is circulated on the Internet to complete the print settings. Therefore, download this file first.
:
Http://www.meadroid.com/scriptx
After the download, add the control to Your webpage: <Object ID = "xprint" style = "display: none" viewastext
Classid = "CLSID: 1663ed61-23eb-11d2-b92f-008048fdd814" codebase = "scriptx. Cab # version = 0,360,">
</Object>. Note that codebase = "scriptx. Cab # version = 0,360," must be modified. Replace "scriptx. Cab" with your own storage path.
Yes.
Or the format problem. First add <style media = "print">. noprint {display: None} </style> to the head, and then set unnecessary elements.
The format of plain is noprint, so that they will not be printed again.
List the content that can be set. All of these items have been tested and can be used with ease.
Xprint. Printing. header = "this is a print test" // Header
Xprint. Printing. footer = "test by guanvee from http://blog.donews.com/guanvee" // footer
Xprint. Printing. Portrait = false // you can specify whether to enable horizontal or vertical playback. True indicates vertical playback and false indicates horizontal playback.
Xprint. Printing. leftmargin = 1 // left margin
Xprint. Printing. topmargin = 1 // top margin
Xprint. Printing. rightmargin = 1 // right margin
Xprint. Printing. bottommargin = 1 // bottom margin
Xprint. Printing. pagesetup () // The print setting window is displayed.
Xprint. Printing. Preview () // The print preview window is displayed.
// Xprint. Printing. Print (true) // print directly. True: The select printer window is displayed. False: Print directly.