Since the invention of the computer, it is natural to print the content in the computer. This is especially true after the Internet era. However, it is not easy to realize the web printing function perfectly, and it is impossible to solve this problem completely.
Remember that Tian rongju (Note:Tian rongju is currently the senior vice president and chief technology officer of Kingdee group. He talked to me privately: "The printing function accounts for two of the total system development workload ". The print function is an important part of system development. Chinese people have always had a good face and often require beautiful printing to reveal the depth of technology. The print function is even more indispensable for Web report tools.
Because of the importance of the printing function, after entering web development, I soon began to pay attention to the development of Web Printing functions. web printing has the following problems to consider:
1 is it printed on the client or server? Considering the speed of data transmission to the client, it is a good choice to print large data volumes on the server. However, printing in the background is inconvenient, so it is mainly necessary to print on the client, that is, printing on the client printer.
2. Is it printed after being exported as a PDF or Excel file or directly? The content to be printed is generated as a PDF or Excel file and then printed. This is also a method, in fact, there is almost no need to specifically consider the development of the printing function, less development workload. But its disadvantage is also obvious: the client needs to install the software to open the PDF (or Excel software), it needs to be printed in another software, there are many steps, can not achieve click to print directly, this printing mode cannot determine whether a document is printed and saved as a sign.
3 is ie printing or self-printing? If all the printing functions are implemented by yourself, because printing of data, styles, positions, images, etc. cannot be processed in a small amount of natural programs, it will usually cause a large download volume for the first time. The process of transferring data to be printed to the print control is complex and slow.
4 do I need to download the ActiveX control when I print it for the first time? If not, you cannot use a Javascript script program to control the printer on the client, customize the paper, and print the printer directly without the pop-up dialog box. That is to say, the end user needs to manually select the printing parameters (such as the printing direction and the paper size) during each printing, which obviously makes the operation of the end user more troublesome.
At first, I designed to directly use JavaScript scripts to calculate pages and directly use the printer mechanism in IE to solve the printing problem. Later, with the upgrade of IE, the security mechanism was constantly improved. Without downloading ActiveX plug-ins, the security mechanism of IE cannot allow you to use JavaScript scripts to fully control the printer on the client. If this is the case, it is possible that when you browse a web page on the Internet, the printer you connect will automatically start printing things. In other words, to make web printing easier, you must download the plug-in from the client. With the flood of rogue plug-ins in China, everyone is afraid of plug-ins. It is not convenient to download the plug-in or print the plug-in. This is the end of web printing. In addition, I think that the same child cannot be unlocked, which is really embarrassing for web printing.
Since the best method is undefined, let's move to the next level. Use a small lightweight ActiveX Control to control the printer on the client, so that the first download of this ActiveX control will not be very slow.
I remember when I was selling Web Print controls, a user told me about the scriptx website and said that I would buy it if I could implement this function. So we started to study scriptx. According to my previous experience in Visual C ++ programming, I think it is generally implemented using hook functions. In combination with IE's printing template technology, it was finally achieved. Visual c ++'s ATL (instead of MFC) is used to make a webprint. DLL, this webprint. after the DLL is compressed into a cab file, it is only 75 kb, which is the same size as a webpage. In this way, the first download will not be too slow. Because the real printer system still calls the internal IE, it is not in webprint. DLL to implement the specific printing function, so you do not need to pass the content to be printed to webprint. DLL, which is different from other ActiveX controls for web printing. If ActiveX controls are used to implement all the printing functions, the printed content must be transmitted to ActiveX controls. This transfer process will be troublesome and slow. Webprint. DLL only transmits the basic printing parameters (such as page size, page margin, and printing direction) to the internal printing function module of IE ), the content displayed on the web page is printed without being printed to webprint. DLL transfers the printed content. As shown in the following figure:
In fact, the printing requirement is very simple. It is nothing more than pagination, header and footer, page margin, printing direction, custom paper, direct printing, pop-up Print dialog box, print, preview, hide and print, batch printing, nesting, and other functions are fixed, clear, and common. Printing a multi-page report on one page is a simple requirement, but it is quite troublesome on the web page. I did not realize it in Table E until recently, just like the CS program, click the button to print the reports of multiple pages on one page. This should take into account the paging processing when a large amount of data is transferred from the server to the client on the Internet, as well as printing one page of data and then passing another page of data. If all the pages to be printed are sent from the server to the client at a time, the speed of the current Internet may be slow. Only one page of data can be sent from the server to the client each time, and then the next page of data can be sent to the client and then printed until the printing ends. This is also a problem where web printing is more troublesome than printing C/S programs.
In short, web printing has become one of the challenges of Web applications, just as it is slow to browse Web pages. Only some trade-offs can be made. For example, because of the popularity of PDF viewing tools in foreign countries, most of them choose to generate PDF files and then print them. I have studied web printing solutions for many years and finally adopted the web printing solution of lightweight ActiveX controls, which is the most suitable solution for China's national conditions. Maybe we can find something better in the future.
To be continued...
Related links:
[Original] Web report development technology Topic 1: Sequence Number Problem
[Original] Web report development technology Topic 2: report tool core-dataset Transformation
Web report development technology Topic 3: irregular grouping and cross-row group operations
Web report development technology Topic 4: The story behind the report designer
Web report development technology Topic 5: the shadows of Excel
Tabulation Efficiency Analysis of Web report tools
Comparison of several web RePort Printing Solutions