Disclosure of Invention
In order to solve the problems, the invention provides a cross-platform hybrid printing method and a system based on a PDF virtual printer.
According to some embodiments, the first scheme of the present invention provides a cross-platform hybrid printing method based on a PDF virtual printer, which adopts the following technical scheme:
a cross-platform hybrid printing method based on a PDF virtual printer comprises the following steps:
creating a target PDF virtual printer in a print client;
The printing client acquires a printing task and an initial printing file of a user, and selects a target PDF virtual printer corresponding to a target client;
The printing client generates a printing file from the initial printing file according to the printing task, converts the printing file format by using a target PDF virtual machine, obtains a PDF printing intermediate file and sends the PDF printing intermediate file to the target client;
And the target client receives the PDF printing intermediate file and performs printing approval, if the approval passes, the PDF printing intermediate file is processed and then sent to a physical printer for printing output, and otherwise, the printing is terminated.
Further, the creation of the target PDF virtual printer in the print client means that the target PDF virtual printer corresponding to a plurality of different target clients within the connectable range is created in the print client.
Further, the print-based client generates a print file from the initial print file according to the print task, converts the print file format by using the target PDF virtual machine, obtains a PDF print intermediate file, and sends the PDF print intermediate file to the target client, specifically:
when the printing client is a Windows operating system, the initial printing file is processed by a printing background processing service to generate a printing file in an EMF/XPS format;
The target PDF virtual printer converts the EMS/XPS format printing file into a PDF format PDF printing intermediate file;
When the printing client is a Linux operating system, the target PDF virtual printer directly generates a PDF printing intermediate file in a PDF format from the initial printing file through processing of a universal Unix printing system.
Further, the target PDF virtual printer converts the EMF/XPS format printing file into a PDF format PDF printing intermediate file, specifically:
initializing a PS/XPS interpreter;
Acquiring an EMF/XPS format print file, and analyzing the print file into an internal graphic command by using an initialized PS/XPS interpreter;
Rendering the internal graphic command by using a rendering engine, converting the internal graphic command into a graphic state update and command, and then carrying out image preprocessing on the graphic state update and command in combination with an internal graphic library to generate an internal image;
Generating PDF objects, page numbers and resources correspondingly based on a PDF file infrastructure according to the internal image generated by the rendering engine;
and storing the internal image in an object of the PDF file through a content stream, processing font embedding and sub-set operation, and synthesizing to obtain the PDF printing intermediate file.
Further, the target client receives the intermediate file printed by PDF and performs printing approval, if the approval passes, the intermediate file printed by PDF is processed and then sent to a physical printer for printing output, specifically:
the target client receives the PDF printing intermediate file and authenticates the user authority of the PDF printing intermediate file;
if the user authority authentication is successful, the approval is passed, and when the target client is a Windows operating system, the PDF printing intermediate file is rendered to obtain a PDF rendering printing intermediate file;
and the PDF rendering and printing intermediate file processed by the printing background processing service is sent to a physical printer for printing and outputting.
Further, the target client receives the intermediate file printed by PDF and performs printing approval, if the approval passes, the intermediate file printed by PDF is processed and then sent to a physical printer for printing output, specifically:
the target client receives the PDF printing intermediate file and authenticates the user authority of the PDF printing intermediate file;
if the user authority authentication is successful, the approval is passed, and when the target client is a Linux operating system, the PDF printing intermediate file is directly sent to a physical printer for printing and outputting.
Further, the print client sends the PDF print intermediate file to the target client via the file transfer service.
Further, the print client obtains the print task and the initial print file of the user, and selects a target PDF virtual printer corresponding to the target client, specifically:
acquiring a print task and an initial print file of a user;
Determining a target client according to the print task;
and selecting a corresponding target PDF virtual printer according to the target client.
According to some embodiments, a second scheme of the present invention provides a cross-platform hybrid printing system based on a PDF virtual printer, which adopts the following technical scheme:
The cross-platform hybrid printing system based on the PDF virtual printer comprises a printing client and a target client;
The printing client is used for acquiring a printing task and an initial printing file of a user and selecting a target PDF virtual printer corresponding to the target client; generating a print file from the initial print file according to the print task, converting the print file format by using a target PDF virtual machine, obtaining a PDF print intermediate file and transmitting the PDF print intermediate file to a target client;
The target client is used for receiving the PDF printing intermediate file and performing printing approval, if the approval passes, the PDF printing intermediate file is processed and then sent to the physical printer for printing output, otherwise, the printing is terminated.
Further, the printing client is a client of a Linux operating system or a client of a Windows operating system;
The target client is a client of a Linux operating system or a client of a Windows operating system.
Compared with the prior art, the invention has the beneficial effects that:
The invention realizes seamless print task transmission and printing between Windows and Linux through the cross-platform support, PDF virtual printer and network transmission mechanism. And the method is easy to deploy, does not need complex driver configuration, and can be used for installing a PDF virtual printer and simply configuring network transmission service by a user. The flexibility is strong, a plurality of network transmission protocols are supported, and the method is suitable for different network environments. The remote printing service can be compatible with various printer drivers, and the smooth completion of the printing task is ensured. By standardization of PDF format, drive compatibility problem among different operation systems is avoided, and complexity of system maintenance and management is reduced.
Detailed Description
The invention will be further described with reference to the drawings and examples.
It should be noted that the following detailed description is illustrative and is intended to provide further explanation of the invention. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
It is noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of exemplary embodiments according to the present invention. As used herein, the singular is also intended to include the plural unless the context clearly indicates otherwise, and furthermore, it is to be understood that the terms "comprises" and/or "comprising" when used in this specification are taken to specify the presence of stated features, steps, operations, devices, components, and/or combinations thereof.
Embodiments of the invention and features of the embodiments may be combined with each other without conflict.
Example 1
The embodiment provides a cross-platform hybrid printing method based on a PDF virtual printer. In this embodiment, the method includes the steps of:
creating a target PDF virtual printer in a print client;
The printing client acquires a printing task and an initial printing file of a user, and selects a target PDF virtual printer corresponding to a target client;
The printing client generates a printing file from the initial printing file according to the printing task, converts the printing file format by using a target PDF virtual machine, obtains a PDF printing intermediate file and sends the PDF printing intermediate file to the target client;
And the target client receives the PDF printing intermediate file and performs printing approval, if the approval passes, the PDF printing intermediate file is processed and then sent to a physical printer for printing output, and otherwise, the printing is terminated.
The method comprises the steps of creating a target PDF virtual printer in a printing client, wherein the step of creating the target PDF virtual printer in the printing client is to create target PDF virtual printers corresponding to a plurality of different target clients within a connectable range. It can be understood that the user authority management function is integrated in the target client, and an administrator can set the printing authorities of different users, so that reasonable use and safe management of printing resources are ensured. That is, the creation of the plurality of target PDF virtual printers described in the present embodiment is performed within the allowable range.
The printing client acquires a printing task and an initial printing file of a user, and selects a target PDF virtual printer corresponding to the target client, wherein the method specifically comprises the following steps:
acquiring a print task and an initial print file of a user;
Determining a target client according to the print task;
and selecting a corresponding target PDF virtual printer according to the target client.
The print file is generated by the initial print file according to the print task based on the print client, the print file format is converted by the target PDF virtual machine, and the PDF print intermediate file is obtained and sent to the target client, specifically:
when the printing client is a Windows operating system, the initial printing file is processed by a printing background processing service to generate a printing file in an EMF/XPS format;
The target PDF virtual printer converts the EMS/XPS format printing file into a PDF format PDF printing intermediate file;
When the printing client is a Linux operating system, the target PDF virtual printer directly generates a PDF printing intermediate file in a PDF format from the initial printing file through processing of a universal Unix printing system.
The target PDF virtual printer converts the EMF/XPS format printing file into a PDF format PDF printing intermediate file, specifically:
initializing a PS/XPS interpreter;
Acquiring an EMF/XPS format print file, and analyzing the print file into an internal graphic command by using an initialized PS/XPS interpreter;
Rendering the internal graphic command by using a rendering engine, converting the internal graphic command into a graphic state update and command, and then carrying out image preprocessing on the graphic state update and command in combination with an internal graphic library to generate an internal image;
Generating PDF objects, page numbers and resources correspondingly based on a PDF file infrastructure according to the internal image generated by the rendering engine;
and storing the internal image in an object of the PDF file through a content stream, processing font embedding and sub-set operation, and synthesizing to obtain the PDF printing intermediate file.
The target client receives the PDF printing intermediate file and performs printing approval, and if the approval passes, the PDF printing intermediate file is processed and then sent to a physical printer for printing output, specifically:
the target client receives the PDF printing intermediate file and authenticates the user authority of the PDF printing intermediate file;
if the user authority authentication is successful, the approval is passed, and when the target client is a Windows operating system, the PDF printing intermediate file is rendered to obtain a PDF rendering printing intermediate file;
and the PDF rendering and printing intermediate file processed by the printing background processing service is sent to a physical printer for printing and outputting.
The target client receives the PDF printing intermediate file and performs printing approval, and if the approval passes, the PDF printing intermediate file is processed and then sent to a physical printer for printing output, specifically:
the target client receives the PDF printing intermediate file and authenticates the user authority of the PDF printing intermediate file;
if the user authority authentication is successful, the approval is passed, and when the target client is a Linux operating system, the PDF printing intermediate file is directly sent to a physical printer for printing and outputting.
And the printing client sends the PDF printing intermediate file to the target client through the file transfer service.
As shown in fig. 1, the invention relates to a computer printing technology, and is a method for realizing cross-platform hybrid printing by a PDF virtual printer, wherein the flow is as follows:
step 0, creating a target PDF virtual printer (supporting Windows, linux operating systems), referred to herein as creating a target PDF virtual printer in the print client that initiates the print job.
Step 1, a user initiates a printing task. The print client obtains the text document and the office document, opens the text document and the office document by using the text document and the WPS office software, initiates a print task, and selects a created target PDF virtual printer for output.
And 2, processing the printing client and the target PDF virtual printer. In the print client of Windows operating system, via spooler service process, EMF/XPS format print file is generated, while the target PDF virtual printer converts the EMF/XPS format print file into PDF format, and in the print client of Linux operating system, via caps service process, PDF virtual printer directly generates PDF print intermediate file in PDF format.
In the print client of the Windows operating system, the monitor dynamic library portmonitor. Dll of the target PDF virtual printer would be loaded by spooler services. Within the monitor dynamic library, several important core callback functions pfnEnumPorts (enumerating ports available in the system), pfnOpenPort (opening a specified port), pfnStartDocPort (informing the monitor that a document has started printing), pfnWritePort (writing data to a port), pfnEndDocPort (informing the monitor that a document has completed printing), pfnClosePort (closing an open port), etc. are all monitored significantly, with the core functions of the virtual printer implemented within the pfnWritePort callback functions. In the pfnWritePort callback function, the monitor can obtain each page of data to print, where it is converted to the PS/XPS format of EMF. PS is a conventional data format, and data can be converted in one-to-one correspondence with PDF data for each page. XPS is a new XML format, and the XPS format of XML is further extracted, parsed, translated and converted into PDF format. After the entire printing action is completed, the intermediate PDF file is also completed to be generated.
The target PDF virtual printer converts the EMF/XPS format print file into PDF format, and the detailed process is as follows:
1) A PS/XPS interpreter is first initialized. The PS interpreter is used to interpret the PostScript language, interpret the PostScript language as an internal graphics command, i.e. parse the EMF PS formatted data into an internal graphics command. The XPS interpreter is essentially an XML parser (XPS is based on a new XML format) that parses XPS data into internal graphics commands.
2) And secondly, when the parser parses the PS/XPS data, a series of runtime environments are provided for providing operation stacks, dictionary stacks, operation states, execution states and the like for the parser parsing.
3) A rendering engine is generated. After parsing the PS/XPS data into internal graphics commands, the rendering engine accepts these commands and translates them into graphics state updates and commands describing the page content to be drawn.
4) The rendering engine will update and command the graphics state, in conjunction with the internal graphics library, to generate internal images according to different graphics functions (image scaling, rotation, conversion, etc.).
5) The final step is the synthesis and output of the PDF. An infrastructure of a PDF file is generated, and contents such as PDF objects, page numbers, resources and the like are correspondingly generated according to the contents generated by the rendering engine. The graphic images generated by the renderer are stored in separate objects of the PDF file via the content stream. Finally, the operations of font embedding, sub-set and the like are processed to ensure that the PDF file can correctly display the text. After the PDF file is synthesized, the intermediate PDF file is also generated.
And step 3, processing by the target PDF virtual printer to obtain the PDF printing intermediate file generated in the step 2.
And 4, file transmission. The PDF print intermediate file is transferred to the target client system (Windows/Linux) via file transfer services (FTP, http/https, minio, etc.).
And 5, target client approval. The PDF printing intermediate file reaches a target client system (Windows/Linux), at the moment, an administrator can conduct printing approval, other steps can be continued after the approval passes, and if the approval passes, printing is directly terminated.
And 6, rendering the PDF file. In the target client of the Windows operating system, the PDF prints the intermediate file, which is rendered first and then printed out by the physical printer. And a target client under the Linux operating system does not need task processing.
And 7, the target client under the Windows operating system prints the intermediate file by the rendered PDF, and sends the intermediate file to a physical printer for printing and outputting through spooler services. And the target client under the Linux operating system directly transmits the PDF printing intermediate file and transmits the PDF printing intermediate file to the physical printer for printing output by the caps service.
Specifically, the embodiment also records the log of the printing tasks, integrates the log recording function in the remote printing service, records the detailed information (such as the submitting time, the printer name, the user ID and the like) of each printing task, and is convenient for audit and fault elimination.
In the embodiment, the virtual printer is not required to be installed on the server, is installed on the terminal, and does not depend on RDP virtual data channels. At the terminal, page-by-page printed data can be acquired, PS/XPS data can be converted into PDF files page by page, and finally the PDF files are combined into a complete PDF file. The present technique does not retain the original PS/XPS data. The technology supports the mutual printing between Windows/Linux operating systems.
The embodiment does not need script, and is the conversion logic of the dynamic library program execution in the virtual printer.
Example two
The embodiment provides a cross-platform hybrid printing system based on a PDF virtual printer, which comprises a printing client and a target client;
The printing client is used for acquiring a printing task and an initial printing file of a user and selecting a target PDF virtual printer corresponding to the target client; generating a print file from the initial print file according to the print task, converting the print file format by using a target PDF virtual machine, obtaining a PDF print intermediate file and transmitting the PDF print intermediate file to a target client;
The target client is used for receiving the PDF printing intermediate file and performing printing approval, if the approval passes, the PDF printing intermediate file is processed and then sent to the physical printer for printing output, otherwise, the printing is terminated.
Further, the printing client is a client of a Linux operating system or a client of a Windows operating system;
The target client is a client of a Linux operating system or a client of a Windows operating system.
The first client is a client of a Linux operating system or a client of a Windows operating system, and the second client is a client of the Linux operating system or a client of the Windows operating system. That is, the printing process described in this embodiment may be PDF printing between Linux operating systems, or PDF printing between Linux operating systems and Windows operating systems, or PDF printing between Windows operating systems and Linux operating systems.
The foregoing embodiments are directed to various embodiments, and details of one embodiment may be found in the related description of another embodiment.
While the foregoing description of the embodiments of the present invention has been presented in conjunction with the drawings, it should be understood that it is not intended to limit the scope of the invention, but rather, it is intended to cover all modifications or variations within the scope of the invention as defined by the claims of the present invention.