Web page printing method (browser Universal)

Source: Internet
Author: User

Web Print Component Jatoolsprinter

Application of the Web, regardless of developers, or users, is a very economical choice, because web-based applications, the client's rules are simple, easy to learn, easy to maintain, easy to publish. But for programmers, because of the limitations of the browser, there are many challenges to face. How to make a Web-based set of hits is such a headache for most programmers.
The difficulty of web-based nesting is to accurately print the HTML rendered in the browser to the ticket, and to control the paging location. The following on the Internet Explorer can be used by the set of solutions, to a summary analysis, I hope to be helpful to everyone.

Jatoolsprinter is a free tool for Web page set-up. The feature of this tool is that it is possible to print pages directly on a Web page, which not only makes the "web-page set-up to be designed" a possibility, but also puts the project managers out of a budget strain. By embedding controls in Web pages, Jatoolsprinter solves problems such as accurate printing of Web clients, batch printing, automatic retention of print configurations, and so on. Jatoolsprinter official free version, support ie6+,http://printfree.jatools.com.

Functional Features:
Real free, no watermark, no IP or domain name restrictions, unlimited time, compatible with ie6+
No registration required, download is available
Microsoft digital Signature Cab Auto-install package for easier installation
Long-term upgrade guarantee, free forum support, let you no worries
Stable and reliable, starting speed far better than similar products
Common function set in one, simple and not simple, software size only 84k

This article mainly introduces Jatoolsprinter print control to complete the printing function of the Web, this control has already encapsulated the printing function is very good, mainly to introduce this control, and then write some simple JS code to complete the corresponding printing function.

<!DOCTYPEHtmlPublic"-//w3c//dtd XHTML 1.0 transitional//en""Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><Htmlxmlns= "Http://www.w3.org/1999/xhtml"><HeadRunat= "Server"><Title></Title><!--inserting print controls--<ObjectId= "Jatoolsprinter"ClassID= "clsid:b43d3361-d075-4be2-87fe-057188254255"CodeBase= "jatoolsprinter.cab#version=5,7,0,0"></Object><ScriptType= "Text/javascript">function Doprint (how) {Print Document objectsvar MyDoc = {documents:document,The print pages (DIV) are copyrights in this document:' Jie Chuang software has copyright www.jatools.com 'Copyright notice must};Calling the Print methodif (how = =' Print preview ... ') Jatoolsprinter.printpreview (MYDOC);Print PreviewElseif (how = =' Print ... ') Jatoolsprinter.print (MyDoc,true);Print Setup dialog box appears before printingelse Jatoolsprinter.print (MYDOC,FALSE);Do not eject dialog box to print}</Script></Head><Body><FormId= "Form1"Runat= "Server"><DivId= ' Page1 'Style= ' width:300px;height:300px; '> Test</Div><InputType= "button"Value= "Print Preview ..."onclick= "Doprint (' Print preview ... ')" />  <input type= "button" value= "Print ..." onclick= "Doprint (' Print ... ')" />  <input type= "button" value= "print" onclick= "Doprint (' print ')" /> </form></ Body></html>   

It is divided into several main steps:

First, the introduction of the print control Jatoolsprinter

<!--Insert a print control-<object id="Jatoolsprinter" classid="CLSID: b43d3361-d075-4be2-87fe-057188254255 "codebase=" jatoolsprinter.cab#version=5,7,0,0 "> </object> 

Second, give the div to be printed ID name

Third, write the JS code to achieve the function of the print div

(Note: On the same page, there are multiple printable documents, they can use the Page_div_prefix property to differentiate the Page_div_prefix prefix +page+ the page number that forms the ID of the printable div, such as the prefix ' Report1 ', to find the ' Report1page1 ' as the ID of the DIV as the document first page of this property, the default value is empty)

Precautions:

1. When the control prints the specified Div object, if the paper is too small to print, the excess will be truncated (clip).
2. The contents of the specified div can be any visible object, picture, Flash, or text, etc. of HTML.
3. When the control prints, the margin can be set, and the printer default value is not set.
4. div ID must be continuous, if your div, there is ' Page1 ', ' page2 ', ' page4 ', and there is no ' page3 ', then the control only prints the first two pages, ' Page4 ' will not be printed.
5. The position of the Div object in the page can be arbitrary, for example, Page1 displayed behind Page2, is also legal.
6. The specified div will be printed, and HTML elements that are not specified will not be printed, for example, the ' print ' button in this example will not be printed.
7. The Copyrights property is copyright information and must be written.

Web page printing method (browser Universal)

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.