Web Print Control Design

Source: Internet
Author: User

I developed a B/S project some time ago and need to use the print function. For example, I search for web printing controls on the Internet, in this way, you do not need to develop your own resources. Many times it is difficult to develop your own services. Besides, you can afford to pay a registration fee of hundreds of RMB or even a few days, its wages are far more than that .), However, I was disappointed to find a Web print. I did not expect the complexity of the commercial web printing controls circulating on the Internet, I had to create a web printing control myself and it was quite easy to use it in the project. Later I had a few friends who wanted to use the web printing function, so I sent them this control, they said it was quite good to use.

The Web Print controls circulating on the Internet are mainly divided into two types: Crystal Report School and IE print School. The crystal report school is of course represented by the crystal report. This feature is to first design the report file, then organize the data source in the program, call the report file, and then preview or print it. In ie printing School, web printing controls in China are usually the same. register an ActiveX control on the user client and use JavaScript to define the report format, define the data content of the report (which can also be read through the URL), and then preview or print the report using the print API of windows.

As a report tool recommended by Microsoft, crystal report is powerful, but can only be used currently.. NET platform, its general version features are also limited, for example, cannot be printed directly, cannot customize the size of the paper, and so on. I have also downloaded several controls for trial using IE printing. I found that the report design is cumbersome. It is both a zombie and a zombie. It uses JavaScript to define the report format and organize the report data, as if I had suddenly returned to the DOS era, an operation window had to calculate the coordinates of each display first, and then draw them one by one. Such a report design was so frustrating, one or two reports can barely match each other. If you do more, it will be exhausting, and it will be troublesome to maintain and modify the report in the future.

As the core of report design, I think whether it is the C/S architecture or the B/S architecture, there are only two points: one is the report data source and the other is the report format. No matter how complicated a report is, it cannot be separated from these two points. As a data source for reports, we are used to using SQL statements. Of course, for overly complex analysis reports, sometimes we have to generate temporary tables first and organize data through complicated programs, then print. Report Format we usually use the report design tool to design the report and save it as a file. To print a report in a program, organize the dataset first, call the report file, pass the parameters required for the report, and preview or print the report.

In the C/S architecture, the printing is mature. You can preview or print the report directly by clicking the button. The Design of reports is also very mature. Both the ancient FoxPro, VB, and Delphi can carry out convenient and efficient report design. As long as the reports are not very complex and the tools are skilled, you can make more than a dozen reports a day.

I want to design reports in B/S architecture based on the design concept of C/S architecture, and separate the data sources and report formats of reports, use a report tool for the C/S architecture to generate reports for the B/S architecture. This allows for convenient and efficient report design in the C/S architecture, in addition, the B/S architecture can be distributed. Of course, due to the particularity of the B/S architecture, the existing printing, especially the use of custom paper size and direct printing functions, have to use ActiveX control.

I designed and developed my own Web Print control based on the concept of designing B/S architecture reports using the C/S architecture report tool. The report tool for this control is fastreport, the function of this report tool is comparable to that of the crystal report, and it is quite simple to use. In order to adapt to the Chinese-style report dashes, I also developed 6 design buttons Based on fastreport: the six buttons are used to add the border and alignment function of fastreport, you can draw table lines efficiently and accurately.

With this design tool, we can design reports very efficiently and do not need to draw reports in a very primitive way. However, you still need to solve the problem of how the data and report formats of the server are transmitted to the client computer. XML can be used as a universal network language as a carrier for transmission. Of course, the conversion is required. The conversion may be different for different languages and databases, in this example, I will detail how to convert common languages and databases. If you are interested, you can download them and check them out.

The Web Print control I designed is certainly not perfect, because the report data is transmitted to the client at one time. If the data is large, the user waits too long, this can be controlled in the program to detect how many pages of data exceed, prompting users to print multiple times to avoid this problem.

The report control itself has more than 800 K, but I don't think this is a problem, that is, the 2 M bandwidth can be downloaded in three or four seconds. The so-called lightweight print controls, there are also more than 200 K, as long as the report control is easy to use, it doesn't matter if it is bigger, just download it once anyway. There are other reports that have not yet applied for a digital license. If there are more users and there is money, I will apply, haha. However, the flash control, as the king of ActiveX controls, is now manually installed. It seems that this does not matter, and you do not need to hand over the silver to Microsoft for verification.


Demo URL of the Web Print control I designed: http://www.xinyuerj.com/ASP/


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.