A printing implementation method, device, system, and storage medium
By adding a client printer to the cloud desktop virtual machine and using the print port monitor to intercept data, the problem of slow cloud desktop printing and inaccessible terminals is solved, achieving an efficient and stable printing process that is suitable for a variety of operating systems.
Patent Information
- Application Number
- CN201910479974.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-06-04
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2039-06-04
AI Technical Summary
In a cloud desktop environment, the traditional printer redirection method is slow and cannot effectively solve the problem of terminal inaccessibility after NAT, affecting the user's printing experience.
Add the client's printer to the virtual machine, intercept the print data through the print port monitor, convert it into virtual print port information, and send it to the client. The client determines the target printer for printing based on the virtual print port information, achieving more efficient and stable printing. process.
It improves cloud desktop printing speed, realizes data interception in user mode, does not involve kernel mode drivers, improves stability and efficiency, is suitable for multiple operating systems, and does not affect other functions of virtual machines and operating systems.
Smart Images

Figure CN112035074B
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to, but are not limited to, a printing implementation method, device, and system, and a computer-readable storage medium. Background Art
[0002] As the earliest project in the cloud computing industry, virtual desktop has a huge market size. In recent years, virtual desktop has flourished in China, including banks, armed police forces, government agencies, etc., which have gradually adopted virtual desktop technology to replace traditional PCs (Personal Computers). Virtual desktop is a revolution in enterprise IT architecture, which brings mobile computing experience while meeting the needs of many specific industries.
[0003] For customers such as governments and banks, printers are peripherals that are used most frequently when handling business. Generally, there are two ways to use printers in cloud desktops. One is to share the printer on the terminal and add a network printer in the cloud desktop. This method is only applicable to Windows terminals, and the cloud desktop must be able to access the terminal network. In reality, the terminal is often behind NAT (Network Address Translation), so this condition cannot be met. The second method is to use port redirection (such as USB (Universal Serial Bus), serial port, parallel port) to redirect the printer port to the virtual machine. This method has a relatively slow processing speed. Summary of the invention
[0004] At least one embodiment of the present invention provides a printing implementation method, device and system, and a computer-readable storage medium to improve the cloud desktop printing speed.
[0005] At least one embodiment of the present invention provides a printing implementation method, including:
[0006] Adding a client printer to the virtual machine, wherein the port of the printer is set as a virtual printing port;
[0007] After receiving an instruction to print a target document using a target printer, converting the target document into print data, and transmitting the print data to a print port monitor;
[0008] The print port monitor sends the print data and the virtual print port information of the target printer to the client.
[0009] At least one embodiment of the present invention provides a printing implementation method, including:
[0010] Receiving printing data and virtual printing port information from the virtual machine, wherein the virtual printing port information corresponds to the printer of the client;
[0011] A target printer is determined according to the virtual printing port information, and the print data is written into the target printer for printing.
[0012] At least one embodiment of the present invention provides a printing implementation device, including a memory and a processor, wherein the memory stores a program, and when the program is read and executed by the processor, the printing implementation method described in any embodiment is implemented.
[0013] At least one embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the printing implementation method described in any embodiment.
[0014] At least one embodiment of the present invention provides a printing implementation system, including: a client and a virtual machine, wherein:
[0015] The virtual machine is used to, after receiving an instruction to print a target document using a target printer, convert the target document into print data, transmit the print data to a print port monitor in the virtual machine, and the print port monitor sends the print data and virtual print port information of the target printer to the client;
[0016] The client is used to receive the printing data and virtual printing port information from the virtual machine, determine the target printer according to the virtual printing port information, and write the printing data into the target printer for printing.
[0017] Compared with the related art, in one embodiment of the present invention, a printer of a client is added to a virtual machine, wherein a virtual printing port is set for the port of the printer; after receiving an instruction to print a target document using a target printer, the target document is converted into printing data, and the printing data is transmitted to a printing port monitor; the printing port monitor sends the printing data and the virtual printing port information of the target printer to the client. The solution provided by this embodiment intercepts data in user mode, does not involve kernel mode drivers, is more efficient and stable, and does not affect the entire system of the virtual machine or other functions of the operating system.
[0018] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings are used to provide a further understanding of the technical solution of the present invention and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the technical solution of the present invention and do not constitute a limitation on the technical solution of the present invention.
[0020] Figure 1 is a schematic diagram of a virtual desktop using a printer in the related art;
[0021] Figure 2 It is the Windows print framework diagram;
[0022] Figure 3 It is a static view of a virtual machine printer redirection module provided by an embodiment of the present invention;
[0023] Figure 4 is a flow chart of a printing implementation method provided by an embodiment of the present invention (virtual machine side);
[0024] Figure 5 This is a flow chart of a printing implementation method provided by an embodiment of the present invention (client side);
[0025] Figure 6 is a flow chart of virtual machine printer redirection provided by an embodiment of the present invention;
[0026] Figure 7 is a block diagram of a printing implementation device provided by an embodiment of the present invention;
[0027] Figure 8 is a block diagram of a computer-readable storage medium provided by an embodiment of the present invention;
[0028] Fig. 9 It is a block diagram of a printing implementation system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present invention more clear, the embodiments of the present invention will be described in detail with reference to the accompanying drawings. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other arbitrarily without conflict.
[0030] The steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions. Also, although a logical sequence is shown in the flowchart, in some cases, the steps shown or described can be performed in a sequence different from that shown here.
[0031] like Figure 1As shown, a method for implementing the use of a printer by a virtual desktop in the related art is shown. In this solution, the printer port is redirected to a virtual machine via USB, wherein the terminal includes: a quick-switch driver (UsbHubHook driver): hot-plugs the target device and modifies the device's PID (Product Identify) and VID (Vendor Identify); a LibUsbK driver: loaded as a function driver for the target device; a UsbIp client user-mode program: receives the virtual machine's USB request through a socket and sends it to the LibUsbK driver for processing, and replies the response to the virtual machine; the virtual machine side includes: a virtual USB bus driver: simulates a USB bus and installs a virtual device; a UsbIp server program: transmits the USB request to the terminal and transmits the reply packet to the VHCI (Virtual Host Controller Interface) bus.
[0032] This solution intercepts the print data from the port driver layer (kernel state) in the virtual machine. This solution has the following disadvantages:
[0033] When redirecting, you need to switch the device driver on the terminal, which is a slow process;
[0034] After the redirection is successful, the cloud desktop operating system still needs to load the driver for the printer, which is also a slow process;
[0035] When printing, the virtual machine intercepts URB (USB Request Block) request packets, which are not only in large quantity but also need to be processed serially. After passing through the network, the delay continues to accumulate, resulting in slow response;
[0036] The object of processing is the URB request packet, which is the data form of the kernel layer. In order to intercept and process this data, two drivers need to be developed for the virtual machine and the terminal respectively, plus the service module for network communication. The modules that need to be developed are too many and too complicated.
[0037] Based on the above analysis, this application proposes a printing implementation method and system for using a printer in a cloud desktop by deeply studying the Windows system printing framework. The method is to replace the module in the Windows printing framework in the virtual machine to intercept the printing data and send it to the physical printer on the terminal for printing.
[0038] Figure 2 Prints a frame diagram for Windows. Figure 2As shown, the Windows printing framework includes: a custom interface and configuration plug-in, a configuration module, a rendering plug-in, a rendering module, a Windows configuration file, a print processor, a language monitor, a print port monitor, a third-party data file and language resources, etc., and a bus driver, wherein the configuration module, the rendering module and the bus driver are provided by the Windows operating system, and the custom interface and configuration plug-in, the rendering plug-in, the Windows configuration file, the print processor, the language monitor, the third-party data file and language resources, etc. are provided by the device manufacturer. In one embodiment of the present application, the print port monitor of the virtual desktop (virtual machine) is transformed, and the print port monitor provided by the present application is used to replace the default port monitor in the Windows printing framework, and a virtual print port is created for the printer in the virtual machine to use. When the user prints a document, the print data processed by the printer processor and the printer driver will be transmitted to the print port monitor of the virtual machine, and the print port monitor of the virtual machine will transmit the print data to the client through the network, and the printer in the client will print it. Among them, the print data can be transmitted after lossless compression, and of course, it can also be transmitted directly without compression.
[0039] In addition, the printer management service running in the virtual machine is modified. The printer management service adds the client's printer and sets the printer's port or driver and other properties as the virtual printing port. The printer management service of the virtual machine can monitor the client's connection request, receive the printer list information from the client, and automatically add the printer according to the printer list information. Of course, printers can also be added in other ways, such as adding the client's printer through the administrator's settings.
[0040] In addition, the client is modified so that when a user prints a document, the client receives the print data from the print port monitor of the virtual machine and writes it to the client's printer for printing.
[0041] In one embodiment, all printers on the client are enumerated and sent to the virtual machine when the client is connected; it should be noted that the virtual machine can add printers on the client in other ways, such as manual configuration by the user. In this case, the client may not report the local printer to the virtual machine.
[0042] Figure 3 FIG. 1 is a schematic diagram of a virtual machine printer redirection provided by an embodiment of the present invention. Figure 3As shown, in the virtual machine, the target document is processed by the printer driver and other means to generate print data and send it to the print port monitor. After receiving the print data, the print port monitor sends the print data to the client, and the client writes the print data to the target printer to print. There is a corresponding relationship between the virtual print port and the printer, for example, virtual print port 1 corresponds to printer 1, virtual print port 2 corresponds to printer 2, and virtual print port 3 corresponds to printer 3.
[0043] like Figure 4 As shown, an embodiment of the present invention provides a printing implementation method, including:
[0044] Step 401, adding a printer of the client to the virtual machine, wherein the port of the printer is set as a virtual printing port;
[0045] Step 402, after receiving an instruction to print a target document using a target printer, convert the target document into print data, and transmit the print data to a print port monitor;
[0046] Step 403: The print port monitor sends the print data and the virtual print port information of the target printer to the client.
[0047] The solution provided in this embodiment intercepts print data from the print port monitor layer (user state) in the virtual machine. It is not in kernel state and does not involve kernel state drivers, which makes it more efficient and stable, and does not affect the entire system of the virtual machine or other functions of the operating system. The data transmitted by the virtual machine to the client has been processed by the virtual machine print driver, and the terminal no longer needs to install the printer driver provided by the manufacturer. In addition, it is easy to deploy and has great practical value. The solution provided in this embodiment can stably and efficiently meet the requirements of customers for using printers in virtual machines. It is an extremely practical function and plays a positive role in the promotion of virtual desktops.
[0048] Wherein, in step 401, before the virtual machine adds the printer of the client, it also includes receiving the printer list information sent by the client;
[0049] The printer list information includes all local printers on the client and their attribute information, including: printer name, driver version number, resolution, paper attributes (size, single-sided, etc.), page attributes (color or black and white, number of copies, etc.), port and other printing attributes. The attribute information is saved in the Devmode structure and can be viewed through printer properties and printer preferences.
[0050] The adding of the client's printer in the virtual machine includes: adding the client's printer in the virtual machine according to the printer list information. Specifically, the virtual machine checks whether there is a printer with the same name, if not, automatically adds the printer, if so, skips.
[0051] The setting of the printer port as a virtual printing port includes: modifying the properties of the printer (such as a driver or a port) as a virtual printing port.
[0052] In one embodiment, the print data is in RAW format. Since the RAW format is supported by various printers, the terminal can directly send the print data to the printer without additional processing regardless of the operating system, thereby shielding the differences in the operating systems where the client is located. This includes but is not limited to the same processing of client operating systems such as Linux series, Windows series, Android and iOS series. It should be noted that the present invention is not limited to this, and it can also be print data in other formats.
[0053] In one embodiment, the printing port monitor sending the printing data and the virtual printing port information of the target printer to the client includes: the printing port monitor compresses the printing data and sends the compressed printing data and the virtual printing port information of the target printer to the client. The transmission of the compressed printing data can save bandwidth. After using lossless compression, the bandwidth can be saved by 30% to 50%.
[0054] This embodiment does not involve kernel-mode drivers, is more stable, and does not affect the entire virtual machine system.
[0055] In this embodiment, any changes to document properties or printer properties only need to be made in the virtual desktop, which is in line with the user's thinking habits when using the virtual desktop and does not change the user's usage habits, thereby quickly improving the customer experience.
[0056] The solution provided in this embodiment is applicable to printers with any interface, including but not limited to USB, serial port, parallel port, and network port.
[0057] This embodiment also shields the differences in the operating systems of the virtual desktop clients. The client operating systems of the Linux series, Windows series, Android and iOS series are treated in the same way. According to the present invention, the client operating systems can be Linux, WES, Android and iOS, respectively, and can be matched in different ways to form multiple embodiments.
[0058] Figure 5 Schematic diagram of a printing implementation method provided by an embodiment of the present invention (client side). Figure 5As shown, an embodiment of the present invention provides a printing implementation method, including:
[0059] Step 501, receiving print data and virtual print port information from a virtual machine; wherein the virtual print port information corresponds to a printer on a client;
[0060] The print data refers to data that has been processed by a print driver, etc., and can be directly written into a printer for printing without being processed by a print driver.
[0061] Step 502: determine a target printer according to the virtual printing port information, and write the print data into the target printer for printing.
[0062] In one embodiment, the print data is in RAW format. Since the received RAW format data can be directly sent to the printer by the terminal regardless of its operating system without additional processing, the RAW format print data can be uncompressed or compressed.
[0063] In one embodiment, the method further includes sending local printer information to the virtual machine, which may be all local printers or some local printers.
[0064] The solution provided in this embodiment is applicable to printers with any interface, including but not limited to USB, serial port, parallel port, and network port.
[0065] This embodiment also shields the differences in the operating systems of the client. The client operating systems of the Linux series, Windows series, Android and iOS series are treated in the same way. According to the present invention, the client operating system can be Linux, WES, Android, iOS, respectively, and can be matched in different ways to form a variety of embodiments.
[0066] This embodiment provides a printing implementation method. First, the print port monitor module of the Windows print framework is installed and replaced in the virtual machine. When the user logs in to the virtual desktop, the client enumerates all printers locally and reports the information to the virtual machine. When the user prints a document in the virtual machine, the print port monitor will receive the print data and send the print data to the client through the network connection. The client opens the corresponding printer and directly writes the print data to the printer to complete the printing. Specifically, it includes automatically adding a printer in the virtual machine according to the printer on the terminal and intercepting the print data in the virtual desktop. The process of automatically adding a printer in the virtual machine is as follows:
[0067] After creating the virtual machine, install the print port monitor in the virtual machine. The printer driver provided by the manufacturer also needs to be installed in the virtual machine.
[0068] After the user logs in to the virtual desktop, the client enumerates all local printers and attribute information of the terminal, generates printer list information, and transmits the printer list information to the printer management service of the virtual machine through the network.
[0069] The printer management service in the virtual machine calls the API provided by the print port monitor to add a virtual print port according to the number of printers, and then determines whether the printer in the printer list already exists. If not, the same printer is automatically added according to the received attribute information; then the printer port is modified to a virtual print port according to the index of the printer in the list, and there is a corresponding relationship between the virtual print port and the index of the printer in the list, that is, an index can be determined according to the virtual print port, and the target printer can be determined according to the index.
[0070] The process of intercepting print data in the virtual machine is as follows:
[0071] receiving a print instruction from a user, the print instruction instructing to use a target printer to print a target document;
[0072] After processing the target document, each module in the Windows print framework converts it into print data and passes it to the print port monitor, as well as the virtual print port information of the target printer;
[0073] The printing data is, for example, printing data in RAW format.
[0074] The print port monitor receives the print data and the virtual print port information of the target printer, and sends the print data and the virtual print port information of the target printer to the client;
[0075] The client determines the target printer according to the virtual printing port information, and sends the print data to the target printer for printing.
[0076] Specifically, there is a corresponding relationship between the virtual printing port information and the index of the printer, so an index can be determined according to the virtual printing port information, and the target printer can be determined according to the index.
[0077] Figure 6 A flow chart of a virtual machine using a printer service provided by an embodiment of the present invention. In which, a print port monitor and a printer driver are installed in the virtual machine. Figure 6 As shown, the method includes:
[0078] Step 601, the client starts, logs into the virtual machine, and requests an IP address from the virtual machine agent;
[0079] Step 602, the virtual machine proxy returns the IP address of the virtual machine to the client;
[0080] Step 603, the client and the printer management service establish a socket link;
[0081] Step 604: After the user logs in to the virtual machine, the client enumerates all local printers and attribute information of the terminal, generates printer list information, and transmits the printer list information to the printer management service of the virtual machine through the network.
[0082] Step 605, the printer management service in the virtual machine calls the API provided by the print port monitor to add a print port according to the number of printers;
[0083] Step 606, the printer management service determines whether the printer in the list already exists. If not, the same printer is automatically added according to the received attribute information; if it exists, the printer is skipped;
[0084] Step 607: The printer management service changes the printer port to a virtual print port with the same index according to the index of the printer in the list.
[0085] Step 608: The virtual machine receives a printing instruction, instructing to use a target printer to print the target document.
[0086] Step 609, the target document is processed by the print driver to generate RAW format print data, which is passed to the print port monitor;
[0087] Step 610, the StartDoc function provided by the print port monitor is called to notify the virtual machine agent;
[0088] Step 611, the virtual machine agent notifies the client of the connection through the primary channel;
[0089] Step 612, the client establishes a socket link with the print port monitor of the virtual machine according to the known virtual machine IP address and fixed port number;
[0090] Step 613: The print port monitor obtains the print data in RAW format and the virtual print port information (such as the specific name of the print), and sends the print data and the virtual print port information to the client through the socket link.
[0091] Step 614: the client determines the target printer according to the virtual printing port information, and sends the print data to the target printer for printing.
[0092] Specifically, the client determines an index according to the virtual printing port information, and the index is the index information of the target printer.
[0093] Step 615: After the document printing is completed, the EndDoc function provided by the print port monitor in the virtual machine is called, and the print port monitor disconnects from the client.
[0094] According to the solution provided by this embodiment, the terminal printer can be redirected to the virtual machine for use from the application level, which is more concise and efficient, effectively saving bandwidth usage. In addition, the user experience can be quickly improved, which has practical significance for the promotion of virtual machines.
[0095] like Figure 7 As shown, an embodiment of the present invention provides a printing implementation device 70, including a memory 710 and a processor 720, wherein the memory 710 stores a program, and when the program is read and executed by the processor 720, the printing implementation method described in any embodiment is implemented.
[0096] like Figure 8 As shown, an embodiment of the present invention provides a computer-readable storage medium 80, which stores one or more programs 81. The one or more programs 81 can be executed by one or more processors to implement the printing implementation method described in any embodiment.
[0097] like Fig. 9 As shown, an embodiment of the present invention provides a printing implementation system, including: a client 91 and a virtual machine 92, wherein:
[0098] The client 91 is used to receive the print data and virtual print port information from the virtual machine, determine the target printer according to the virtual print port information, and write the print data to the target printer for printing;
[0099] The virtual machine 92 is used to, after receiving an instruction to print a target document using a target printer, convert the target document into print data, transmit the print data to a print port monitor in the virtual machine, and the print port monitor sends the print data and the virtual print port information of the target printer to the client.
[0100] Among them, other functions of the virtual machine 92 and the client 91 refer to the above-mentioned embodiments and are not described in detail here.
[0101] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those of ordinary skill in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
Claims
1. A printing implementation method, include: Adding a printer of a client in a virtual machine, wherein the virtual machine establishes a network connection with the client and exchanges data through the network, and the port of the printer is set as a virtual printing port; After receiving an instruction to print a target document using a target printer, converting the target document into print data, and transmitting the print data to a print port monitor, wherein the print port monitor interacts with the client through the network to perform print data; The print port monitor intercepts the print data and the virtual print port information of the target printer, and sends them to the client through the network, wherein the client is used to determine the target printer according to the virtual print port information, and write the print data into the target printer for printing.
2. The printing implementation method according to claim 1, It is characterized in that Before the virtual machine adds the printer of the client, the method further includes receiving printer list information sent by the client; The adding a printer of the client in the virtual machine includes: adding the printer of the client in the virtual machine according to the printer list information.
3. The printing implementation method according to claim 1, It is characterized in that The print data is in RAW format.
4. The printing method according to any one of claims 1 to 3, It is characterized in that The printing port monitor sending the printing data and the virtual printing port information of the target printer to the client includes: the printing port monitor compresses the printing data and then sends the compressed printing data and the virtual printing port information of the target printer to the client.
5. A printing implementation method, include: Receiving print data and virtual print port information from a virtual machine, wherein the virtual print port information corresponds to a printer of a client, the virtual machine establishes a network connection with the client and exchanges data through the network, the print data and the virtual print port information are intercepted by a print port monitor in the virtual machine and sent to the client, and the print port monitor exchanges print data with the client through the network; A target printer is determined according to the virtual printing port information, and the print data is written into the target printer for printing.
6. The printing implementation method according to claim 5, It is characterized in that The method further includes sending local printer information to the virtual machine.
7. The printing implementation method according to claim 5 or 6, It is characterized in that The printing data is printing data in RAW format.
8. A printing implementation device, It is characterized in that The method comprises a memory and a processor, wherein the memory stores a program, and when the program is read and executed by the processor, the printing method according to any one of claims 1 to 7 is implemented.
9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the printing implementation method according to any one of claims 1 to 7.
10. A printing implementation system, It is characterized in that include: Client and virtual machine, where: The virtual machine establishes a network connection with the client and exchanges data via the network; The virtual machine is used to, after receiving an instruction to print a target document using a target printer, convert the target document into print data, transmit the print data to a print port monitor in the virtual machine, and the print port monitor intercepts the print data and the virtual print port information of the target printer and sends them to the client through the network, wherein the print port monitor exchanges print data with the client through the network; The client is used to receive the printing data and virtual printing port information from the virtual machine, determine the target printer according to the virtual printing port information, and write the printing data into the target printer for printing.
