How StratoIO WebPrinter Works


            
Background
of the working principle of Strato WebPrinter As software development technology gradually shifts from C/S architecture to B/S architecture, printing has gradually become a problem that Web developers need to face. The increasingly powerful CSS style sheet technology can easily realize complex layout and display, but due to the safe sandbox control of the program by Web technology, the last step of printing: output to the printer is a difficult problem.

We researched a lot of web software and found that there are mainly the following technical implementation methods for web printing solutions:
1. Directly call Javascript to print

By calling the built-in print method of the browser window object, a print window pops up, and the user clicks to confirm the print.

This method is the simplest printing method, and its biggest problem is that it requires a large degree of manual intervention. Users need to manually set headers and footers, page margins, and click the confirm printing button. This greatly reduces the friendliness of the application, and it cannot adapt to some high-frequency operation business scenarios.
2. Browser control printing

Another part of the developers adopts the method of developing browser controls, connecting the browser's printing SDK through the control and providing a Javascript bridge interface for web page calls.

The early representative is in the IE browser, JS calls the browser to print through ActiveX technology. This method of calling local controls at will has proved to be unsafe, and with the rise of browsers such as Firefox and Google, compatibility issues have gradually become prominent.

Due to the high technical threshold of browser control development, such products are often developed by professional control developers and provided for paid use.

Controls solve the problem of interactivity very well. However, depending on the operating system version, number of bits, browser types and versions, browser controls need to develop and maintain different control versions. At the same time, the upgrade speed of mainstream browsers is also very agile, and control developers often cannot keep up with the browser version. pace. In addition, most browsers often require the use of C language development. If a good memory management model is lacking, the control will often crash due to memory problems or even cause the browser to crash.
3. Local proxy

Another way is to install the proxy program locally, the proxy provides the Http service, and the web page submits the print task and receives the feedback through the cross-domain request technology.

The advantage of this method is that it is free from the constraints of the browser and avoids the problem of version delay synchronization caused by browser updates.

The only problem is that this approach requires the user to be prompted to download and install the agent.
Design Ideas

The core idea of ​​Strato WebPrinter is to provide developers with a highly manageable, extremely stable, and highly automated printing solution.

After multiple technical research and analysis, we decided to adopt the third solution, that is, the local agent method, as the core architecture of the application scenario. And using Java as the development language of the agent program, it is expected to provide extremely stable background services through the cross-platform features of Java virtual machine technology and Java's powerful memory management capabilities.
Running scenario
Strato WebPrinter running scenario


Description :

The page does not detect the agent program through the JS API and prompts the user to install it;

the user downloads the installer from the local or CDN and installs it;

after the installation is complete, start the agent program, the webpage automatically detects the agent program, and hides the prompt And switch to normal content;

user interaction or automatic execution of JS API to send print tasks;

JS API to register callback functions or monitor events and modify the task status;

run repeatedly until the printing is completed.
Article source: Reprinted from http://webprint.stratoio.com/doc/theory

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326437611&siteId=291194637