Printing method and device
By introducing proxy units into Winform applications on the Windows platform, the interaction between browsers and printing devices and other peripherals is solved, and the problems of browser permission restrictions and cloud printing network overhead are improved, and operation efficiency and user experience are improved.
Patent Information
- Application Number
- CN201811113932.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2018-09-25
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2038-09-25
AI Technical Summary
In Winform applications on Windows platform, the browser cannot directly read the serial ports of the computer and peripherals due to permission restrictions, resulting in frequent switching of the browser and Winform applications, which is inefficient and poor user experience. In cloud printing technology, after the printed content is completed on the server side, it needs to be transmitted over the network, resulting in large network overhead.
The agent unit realizes the interaction between the browser and the printing device and other peripherals. The agent unit receives the printing content sent by the browser, fills it in the preset template to form the printing data, and outputs it to the printer for printing.
It improves the interaction efficiency between browsers and printing devices, improves user experience, and saves network overhead.
Smart Images

Figure CN110941401B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a printing method, device, electronic equipment and computer-readable medium. Background Art
[0002] In a Winform (a development framework for the Windows platform) application based on Windows (Microsoft Windows operating system), use C# (a programming language) Socket (a communication method) to communicate with other peripherals, and use C# to communicate with the serial port to complete operations, such as printing operations.
[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:
[0004] Because the browser is a window of the client application, it has no permission to read the serial port of the computer and peripherals in Windows, so it is necessary to switch between the browser and Winform applications, which is inefficient and has a poor user experience. In cloud printing technology, the print content is filled on the server before printing, which has a large network overhead. Summary of the invention
[0005] In view of this, an embodiment of the present invention provides a printing method and apparatus, which can realize the interaction between a browser and a printing device and other peripherals through a proxy unit, improve operation efficiency and user experience, and save network overhead.
[0006] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present invention, a printing method is provided, comprising: an agent unit receives printing content sent by a browser; the agent unit fills the printing content into a preset template to form printing data; the agent unit outputs the printing data to a printer for printing the printing data.
[0007] Optionally, the method further includes: the proxy unit acquiring the preset template from a server, and storing the preset template.
[0008] Optionally, the printed content includes an identifier of a preset template.
[0009] Optionally, the browser sends the print content to the proxy unit in an AJAX manner.
[0010] Optionally, the print data is in picture format.
[0011] Optionally, the method further includes: the proxy unit receiving a print result returned by the printer; and the proxy unit returning the print result to the browser.
[0012] Optionally, it also includes: the proxy unit is written in C#, receives data associated with the print content through a hardware interface, and returns the associated data to the browser; the browser forms the print content according to the received associated data.
[0013] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, a printing device is provided, comprising: a browser module, a proxy module and a printing module; wherein the browser module is used to send printing content to the proxy module; the proxy module receives the printing content, fills the printing content into a preset template to form printing data; the proxy module outputs the printing data to the printing module; and the printing module is used to print the printing data.
[0014] Optionally, the proxy module is further used to obtain the preset template from the server and store the preset template.
[0015] Optionally, the printing module is further used to return the printing result to the proxy module; the proxy module is further used to return the printing result to the browser module.
[0016] Optionally, the proxy module is written in C#, and is used to receive data associated with the print content through a hardware interface and return the associated data to the browser module; the browser module is also used to form the print content according to the received associated data.
[0017] To achieve the above-mentioned purpose, according to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement any of the methods described in a printing method.
[0018] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by one or more processors, any method described in a printing method is implemented.
[0019] An embodiment of the above invention has the following advantages or beneficial effects: because a technical means is adopted to enable the browser and the printer to interact through a proxy unit, the technical problems of low efficiency of interaction between the browser and the printer and poor user experience in traditional methods are overcome, thereby achieving the technical effect of improving user experience and operational efficiency.
[0020] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0022] Figure 1 is a schematic diagram of main steps of a printing method according to an embodiment of the present invention;
[0023] Figure 2 It is a schematic diagram of the interaction between the browser, C# proxy unit and printer;
[0024] Figure 3 It is a preferred implementation according to an embodiment of the present invention;
[0025] Figure 4 is a schematic diagram of the main parts of a printing device according to an embodiment of the present invention;
[0026] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0027] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0028] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0029] Figure 1 is a schematic diagram of the main steps of the printing method according to an embodiment of the present invention, such as Figure 1 As shown:
[0030] Step S101 indicates that the proxy unit receives the print content sent by the browser; the print content refers to the print content that needs to be filled in, for example, when printing an express waybill, the print content includes the waybill number, recipient information, sender information, etc., which can be manually entered by the user on the browser. The proxy unit can be a code written in C# language.
[0031] Furthermore, the browser can call the network service interface (a hardware interface for network services) of the proxy unit, and the browser sends the print content to the proxy unit in AJAX (Asynchronous Javascript And XML, JavaScript is a literal scripting language that can add dynamic functions to web pages; XML is extensible markup language, which refers to a web development technology for creating interactive web applications). XML is a style string, and objects are matched to XML placeholders using a loop traversal method (such as the String.Format method) to complete the final combination of style and data. The proxy unit includes a network service (webservice) interface that can be called by the browser. The browser calls the interface and sends the print content to the proxy unit in AJAX mode, that is, the print content is updated and sent to the proxy unit without updating the entire web page of the browser.
[0032] Step S102 indicates that the agent unit fills the print content into the preset template to form print data; wherein the preset template refers to the style of the print content filling, that is, only after the print content is filled into the preset template, can the complete print data be formed for printing. For example, express waybills have pre-fixed style templates, and the agent unit can form a complete and effective express waybill by filling in the express information. The agent unit parses the print content according to the preset template, and each different print data has a corresponding value. For example, user.name in the print data corresponds to the "name" in the preset template, and user.age=12 in the print content corresponds to the "age" in the preset template, and is filled in accordingly.
[0033] Furthermore, the printed content includes an identifier of a preset template. When there is more than one preset template, it means that different printed contents correspond to different preset templates, so the identifier of the preset template is added to the printed content, such as the file name, number, version number, etc. of the preset template, to match the correct preset template.
[0034] The method further includes: the proxy unit obtains the preset template from the server and stores the preset template. The purpose of this step is to update the local preset template according to the server to reduce network overhead. In one embodiment of the present invention, the proxy unit periodically polls the server for preset templates, and when the preset template of the server is updated, the updated preset template is obtained and stored locally.
[0035] Step S103 indicates that the agent unit outputs the filled print data to the printer. The agent unit calls the interface of the printer to send the print data to the printer for printing. For example, the agent unit sends the filled express waybill to the printer for printing.
[0036] In one embodiment of the present invention, the proxy unit outputs the filled print data to the printer in the format of a picture. For example, a GDI+ (Graphics Device Interface plus, a system in Windows responsible for outputting relevant information on a display screen and a printing device) processing unit is used to draw using the Graphics2D (a basic class for presenting two-dimensional shapes, texts, and images on a Java platform) class, and the source of the picture material is the print data.
[0037] Furthermore, the printer returns the printing result to the proxy unit; for example, after the printer finishes printing, it returns a printing completion message to the proxy unit.
[0038] Furthermore, the proxy unit returns the printing result to the browser. After receiving the printing result returned by the printer, the proxy unit returns the returned result to the browser to complete the printing process.
[0039] The proxy unit is written in C#, receives data associated with the print content through a hardware interface, and returns the associated data to the browser; the browser forms the print content based on the received associated data. The proxy unit can communicate with various peripherals through a hardware interface to receive data collected by the peripherals, send the collected data to the browser through a network service interface, or the browser requests to obtain the collected data. Figure 2 As shown, for example, when receiving weight data collected by an electronic scale or volume data collected by a measuring device, the browser directly issues a print request, and the C# proxy unit sends these data to the browser through a network service interface, so that the browser can obtain these collected data from these peripherals in a non-human way, and then form the print content, and the proxy unit then enables the printer to execute printing.
[0040] Figure 3 FIG. 1 is a preferred implementation of an embodiment of the present invention. Figure 3 As shown:
[0041] The C# proxy unit may include a template processing unit, an object parsing unit, a template combining unit and a GDI+ processing unit, wherein the template processing unit is responsible for periodically polling the template, obtaining a preset template for printing labels from a server, and storing the template in the local application memory after obtaining the template, such as pulling the XML style in the server through an HTTP request;
[0042] The user sends a print request through a Web browser, and the print content including the file name of the preset template is sent to the C# proxy unit through AJAX;
[0043] The C# proxy unit receives the printed content and uses an object parsing unit (such as annotator, etc.) to match the printed content into an object that can be recognized by the C# proxy unit; for example, through the json property, the JsonToObject method is used to convert the json string into an object that can be recognized by C#;
[0044] The C# proxy unit uses the template combination unit to fuse the preset template and the object attributes of the print content to complete the filling and form the print data;
[0045] The C# proxy unit uses the GDI+ processing unit and the Graphics2D class for drawing and converts the print data into a picture format;
[0046] The C# proxy unit uses Microsoft's native printer output method to output the printed image to the printer port (USB port or serial port, etc.) to complete the printing.
[0047] The sample code of the C# proxy unit is as follows:
[0048]
[0049]
[0050] Figure 4 FIG. 4 is a schematic diagram of the main parts of a printing device 400 according to an embodiment of the present invention. Figure 4 As shown:
[0051] The device 400 includes a browser module 401, an agent module 402 and a printing module 403;
[0052] The browser module 401 is used to send print content to the proxy module 402; the print content refers to the print content that needs to be filled in, for example, when printing an express waybill, the print content includes the waybill number, recipient information, sender information, etc., which can be manually input by the user on the browser module 401. The proxy module 402 can be a code written in C# language.
[0053] Furthermore, the browser module 401 can call the network service interface (a hardware interface for network service) of the proxy module 402, and the browser module 401 sends the print content to the proxy module 402 in AJAX mode. XML is a style string, and the object is matched to the XML placeholder by a loop traversal method (such as the String.Format method) to complete the final combination of style and data. The proxy module 402 includes a network service (webservice) interface that can be called by the browser module 401. The browser module 401 calls the interface and sends the print content to the proxy module 402 in AJAX mode, that is, the print content is updated and sent to the proxy module 402 without updating the entire web page.
[0054] The proxy module 402 receives the print content, and fills the print content into the preset template to form print data; wherein, the preset template refers to the style of the print content filling, that is, the print content can only be completely printed after it is filled into the preset template. For example, express waybills have pre-fixed style templates, and the proxy module 402 can form a complete and effective express waybill by filling in the express information. The proxy module 402 parses the print content according to the preset template, and each different print data has a corresponding value. For example, user.name in the print data corresponds to the "name" in the preset template, and user.age=12 in the print content corresponds to the "age" in the preset template, and is filled in accordingly.
[0055] The proxy module 402 outputs the filled print data to the printing module 403, and the printing module 403 prints the print data. The print content is filled into the preset template to form print data, and the proxy module 402 calls the interface of the printing module 403 to send the print data to the printing module 403 for printing. For example, the proxy module 402 sends the filled express waybill to the printer for printing. One embodiment of the present invention is that the proxy module 402 outputs the filled print data to the printer in the format of a picture. For example, using the GDI+ (Graphics Device Interface plus, a system in Windows responsible for outputting relevant information on the display screen and printing device) processing unit, using the Graphics2D (a basic class for presenting two-dimensional shapes, texts and images on the Java platform) class for drawing, the source of the picture material is the print data.
[0056] The printing module 403 is also used to return the printing result to the proxy module 402. For example, after the printer finishes printing, a message indicating that the printing is completed is returned to the proxy module 402.
[0057] The proxy module 402 is also used to return the printing result to the browser module 401. After receiving the printing result returned by the printer, the proxy module 402 returns the returned result to the browser module 401 to complete the printing process.
[0058] The proxy module 402 is also used to obtain the preset template from the server and store the preset template. The purpose is to update the local preset template according to the server to reduce network overhead. In one embodiment of the present invention, the proxy module 402 regularly polls the server for preset templates, and when the preset template of the server is updated, the updated preset template is obtained and saved locally.
[0059] The printed content includes the identifier of the preset template. When there is more than one preset template, it means that different printed contents correspond to different preset templates, so the identifier of the preset template is added to the printed content, such as the file name, number, version number, etc. of the preset template, to match the correct preset template.
[0060] The proxy module 402 is written in C# and is used to receive data associated with the print content through a hardware interface and return the associated data to the browser module 401; the browser module 401 is also used to form the print content according to the received associated data. The proxy module 402 can communicate with various peripherals through a hardware interface to receive data collected by the peripherals, and send the collected data to the browser module 401 through a network service interface, or the browser module 401 can request to obtain the collected data. Figure 2 As shown, for example, when receiving weight data collected by an electronic scale or volume data collected by a measuring device, the browser module 401 directly issues a print request, and the C# proxy module sends these data to the browser module 401 through the network service interface, so that the browser module 401 can receive these collected data from these peripherals in a non-human way, and then form the print content, and the proxy module then enables the printer to execute printing.
[0061] Figure 5 An exemplary system architecture 500 is shown in which a printing method or a printing device according to an embodiment of the present invention can be applied.
[0062] like Figure 5 As shown, system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505. Network 504 is used to provide a medium for communication links between terminal devices 501, 502, 503 and server 505. Network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0063] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as printing applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0064] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0065] The server 505 may be a server that provides various services, such as a background management server that provides support for printing websites browsed by users using the terminal devices 501, 502, and 503. The background management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information and product information) to the terminal device.
[0066] It should be noted that a printing method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, a printing device is generally disposed in the server 505 .
[0067] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0068] Figure 6 The diagram is a schematic diagram of the structure of a computer system 600 of a terminal device suitable for implementing an embodiment of the present invention. Figure 6 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0069] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0070] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0071] In particular, according to the embodiments disclosed in the present invention, the process described in the above step diagram can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the step diagram. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0072] It should be noted that the computer-readable medium shown in the present invention includes a computer-readable signal medium or a computer-readable storage medium, or any combination of the above two. Computer-readable storage media include, but are not limited to, electrical, magnetic, optical, electromagnetic, infrared, semiconductor systems, devices or devices, or any combination of the above. Computer-readable storage media specifically include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any combination of the above. In the present invention, a computer-readable storage medium includes any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or device; a computer-readable signal medium includes a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code, and such a propagated data signal can take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any combination of the above signals. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF (radio frequency), etc., or any combination of the above media.
[0073] The step diagram or block diagram in the accompanying drawings illustrates the possible implementation architecture, functions and operations of the system, method and computer program product according to various embodiments of the present invention. Each box in the step diagram or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for implementing the specified logical function. It should be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed in parallel, and sometimes they can be executed in the opposite order, and the execution order depends on the functions involved. It should also be noted that each box in the block diagram or step diagram and its combination can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0074] The modules or units involved in the embodiments of the present invention may be implemented by software or hardware. The modules or units described may also be set in a processor, for example, it may be described as: a processor includes a browser module, a proxy module and a printing module. The names of these modules or units do not constitute a limitation on the modules or units themselves in some cases, for example, the browser module may also be described as "a module for sending print content to the proxy module".
[0075] On the other hand, an embodiment of the present invention further provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: an agent unit receives the print content sent by the browser; the agent unit fills the print content into a preset template to form print data; the agent unit outputs the print data to a printer to print the print data.
[0076] According to the technical solution of the embodiment of the present invention, the interaction between the browser and the printing device and other peripherals can be realized through the proxy unit, thereby improving the operation efficiency and user experience and saving network overhead.
[0077] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A printing method, characterized in that: include: The proxy unit receives the print content sent by the browser, and the proxy unit includes a network service interface that can be called by the browser, so that the browser calls the interface and sends the print content to the proxy unit in an AJAX manner; The proxy unit uses the object parsing unit to match the print content into an object recognizable by the proxy unit, and uses the template combining unit to fuse the preset template and the object attributes of the print content to fill the print content into the preset template to form print data; The proxy unit outputs the print data to a printer to print the print data; The proxy unit is written in C#, communicates with various peripherals through a hardware interface to receive data associated with the print content collected by the peripherals, and returns the associated data to the browser; The browser forms the print content according to the received associated data.
2. The method according to claim 1, characterized in that The method further comprises: The proxy unit obtains the preset template from the server and stores the preset template.
3. The method according to claim 1, characterized in that The printed content includes an identifier of a preset template.
4. The method according to claim 1, characterized in that The browser sends the print content to the proxy unit in an AJAX manner.
5. The method according to claim 1, characterized in that The printing data is in picture format.
6. The method according to claim 1, characterized in that The method further comprises: The proxy unit receives the printing result returned by the printer; The proxy unit returns the print result to the browser.
7. A printing device, characterized in that: include: Browser module, proxy module and print module; Wherein, the browser module is used to send the print content to the proxy module; The proxy module receives the print content, uses an object parsing unit to match the print content into an object recognizable by the proxy unit, and uses a template combining unit to fuse the preset template and the object attributes of the print content to fill the print content into the preset template to form print data; The proxy module outputs the print data to the print module; The printing module is used to print the printing data; The proxy module is written in C# and is used to communicate with various peripherals through a hardware interface to receive data associated with the printed content collected by the peripherals, and return the associated data to the browser module; The browser module is also used to form the print content according to the received associated data; The proxy unit includes a network service interface that can be called by the browser, so that the browser calls the interface and sends the print content to the proxy unit in an AJAX manner.
8. The device according to claim 7, characterized in that The proxy module is also used to obtain the preset template from the server and store the preset template.
9. The device according to claim 7, characterized in that The printing module is also used to return the printing result to the proxy module; The proxy module is also used to return the printing result to the browser module.
10. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by one or more processors, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method for enabling communication between a user device browser and a local device
CN107111465A