Asp. NET Web Printing-the ultimate solution

Source: Internet
Author: User
Asp.net|web|web Printing | The comrades who have done BS should all be aware that printing in a Web program is no longer as easy to control as an application, and some of the inherent features of Web programs create this disadvantage, such as: printers are local, and files are probably on the server , how the format is controlled and customized, and so on. Have brought many problems to our development, although there are Crystal reports and other controls to solve but it is always inconvenient. Of course, there will be some people to solve the problem, here I first of the current popular several ways to do a brief introduction:

1, IE Direct printing

This needless to say, directly call the Window.print or Webrower control of the EXECWB method to print. Convenient and quick, the client does not need any setting. Some methods can also achieve a simple customization, such as a template HTM file, and then in the JS dynamic create a hidden frame, with the script to generate the data, and then the final result file written to the hidden frame printing processing. If handled well, actually the effect is also good. For simple printing needs should be enough. Here I give a practical example to illustrate this approach:
Development often need to print some statistical results to the user, such as a common function is the Business Report class printing: the operator first input query conditions, and then submit the results of the query, click to print, according to the definition of the format of the printed report.
Most of our implementation will bind the results of the query to the DataGrid, and then print the DataGrid. This kind of situation printing generally speaking format is relatively fixed simple, the determination will not make changes basically. So you can use IE direct printing, but if the direct call Window.print to print the page, the other elements of the page will be printed, the end of the page The format is also difficult to control.


2, ActiveX control

Develop your own controls. This is the way many commercial software uses in this way, and it does not matter whether it is used in the Web or in applications when written as a control. The printing method is very flexible, and basically the web can be done by the program. However, the client needs to install components and deployment is not very convenient.

3,. NET components

Lu Yan wrote a very good article, "The use of XML to achieve common Web report printing," I believe that everyone has read. New ideas, simple implementation, is indeed a common web printing solution, especially the use of XML to describe the printing of documents to the future development of the format left a good interface, very easy to expand. This kind of printing method is very suitable for the application of large format change and small amount of data. This kind of thinking also gives a new idea of printing on the ASP.net: customizing some components to achieve flexible printing function. Of course, the disadvantage is also obvious: 1, the need for clients to install the net framework1.0 components. 2, XML parsing, if the file is not very ideal speed. 3, the first load of the page will have a significant delay.



Let's make a list of entries and continue writing tomorrow.




Related Article

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.