WASM plug-in printing method and system based on browser
The browser-based WASM printing plug-in method addresses the limitations of traditional browser printing by using WASM to encapsulate printing functions, providing refined control and cross-platform compatibility for self-service devices.
Patent Information
- Application Number
- CN202410952944.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-16
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-07-16
AI Technical Summary
Traditional browser-based printing methods lack the capability for silent printing on self-service devices and are limited by the use of ActiveX plug-ins, which are not supported by mainstream browsers and introduce communication delays.
A browser-based WASM printing plug-in method that uses a WASM binary file to encapsulate printing functions, allowing seamless interaction with printers through a WASM module, enabling cross-platform silent printing without the need for additional plugins.
Enables refined control and management of printing on self-service devices, supporting various document formats and attributes, and is adaptable across different browsers, overcoming the limitations of ActiveX plug-ins.
Smart Images

Figure CN119065735A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of browser printing technology, and in particular, relates to a browser-based WASM printing plug-in method and system. Background Art
[0002] Traditional browser-based printing mostly involves calling the print window provided by the browser to select a printer, set print properties, and then complete the print operation. This model cannot meet the silent printing needs of personalized self-service printing.
[0003] In response to the above problems, two solutions have been developed for printing on self-service devices: One solution is to deploy an application on the print client, which encapsulates various printing functions. The browser front end needs to communicate with the application and complete various functional services through the corresponding interface. Another solution is based on ActiveX plug-ins.
[0004] In addition to the interface development work, the first solution will also bring additional communication delays; the second solution is not only limited to the Windows operating system, but mainstream browsers such as Google do not support ActiveX plug-ins. Summary of the invention
[0005] Based on this, it is necessary to provide a browser-based WASM printing plug-in method and system to solve the above technical problems.
[0006] In a first aspect, the present application provides a browser-based WASM printing plug-in method, comprising: Obtain a wasm binary file and obtain a wasm plug-in, wherein the wasm binary file can be recognized by the browser; Deploy the wasm plug-in to a web server to obtain a wasm plug-in address, wherein the wasm plug-in address represents the address of the wasm plug-in in the web server; At the front end of the browser, according to the wasm plug-in address, the wasm plug-in is downloaded to obtain a wasm instance; Get the incoming document to be printed, and use the function parameter parsing of the function interface of the wasm instance to process and print the document to be printed.
[0007] In some practicable methods, the step of obtaining a wasm binary file and obtaining a wasm plug-in includes: The source code file is compiled into a printer.wasm binary file using the emcc command of the Emscripten compiler, wherein the export function of the printer.wasm binary file includes a dynamic memory allocation function interface, a dynamic memory release function interface, and a print command execution function interface, wherein the print command execution function interface includes at least a print service type and a print service parameter.
[0008] In some practicable ways, the step of deploying the wasm plugin to a web server and obtaining the wasm plugin address includes: Obtain the web server that supports static file hosting; Store the wasm plug-in in the web server directory to obtain the wasm plug-in address.
[0009] In some practicable methods, the step of downloading at the front end of the browser according to the wasm plug-in address to obtain an instance of wasm includes: JavaScript language is used in the browser front end, and the wasm plug-in is downloaded using the fetch method according to the wasm plug-in address to obtain a wasm instance, wherein the wasm instance represents instantiation of binary data into a wasm instance.
[0010] In some practicable methods, the step of obtaining the incoming document to be printed, parsing the function parameters of the function interface of the wasm instance, and processing and printing the document to be printed includes: According to the input document to be printed, obtaining the input business type and the input business parameters input by the front end, wherein the input business type indicates the type of the document to be printed, and the input business parameters indicate the relevant parameters of the document to be printed; Determining the printing service type according to the incoming service type; According to the printing service type and the corresponding printing service parameters, the input service parameters are parsed to obtain the server address of the document to be printed; According to the server address, the document to be printed is downloaded to the local computer, and the processing result returned by the service is obtained; The success or failure of the processing is determined based on the processing result returned by the service.
[0011] In some practicable methods, the step of downloading the document to be printed to a local computer according to the server address and obtaining the processing result returned by the service includes: Utilizing the printing service parameters, the input service parameters are parsed to obtain the server address fileurl of the document to be printed; According to the server address fileurl of the document to be printed, calling the get method of http to download the document to be printed to the local computer; Then, the printing service parameters are used to parse the input service parameters to obtain the required number of printing sheets; Compare the required number of printing papers with the number of remaining papers in the printing paper box to obtain a comparison result; If the comparison result is that the number of remaining papers is greater than or equal to the number of printing papers, a print instruction is generated; otherwise, a processing failure instruction is generated.
[0012] In some practicable manners, the step of reusing the printing service parameter to parse the input service parameter to obtain the required number of printing sheets includes: Determining the format of the document to be printed according to the binary byte identifier of the document to be printed that is input; If the format of the document to be printed is a PDF file, the document to be printed is parsed to determine the number of pages of the document to be printed; According to the number of printed pages of the pdf file, the printed documents are sent to the printer in sequence; If the format of the document to be printed is a picture, determining the number of pages of the document to be printed; If the format of the document to be printed is not a picture, converting the document to be printed into a picture, and determining the number of pages of the document to be printed; The printed documents are sent to the printer in sequence according to the number of printed pages of the picture.
[0013] In some practicable methods, the steps of sequentially sending the printed documents to the printer according to the number of printed pages of the PDF file, and the steps of sequentially sending the printed documents to the printer according to the number of printed pages of the picture, both include: Before the step of sending the print document to the printer in sequence: Using the printing service parameters, the input service parameters are parsed to obtain the printing attributes of each page of the PDF file or picture, wherein the printing attributes at least include paper direction, paper size and paper box position; The printing attribute is set by using the interface of the operating system, and a PDF file or picture with the printing attribute is obtained accordingly; Send the pdf file or image with printing properties to the printer.
[0014] A second aspect of the present invention provides a browser-based WASM printing plug-in system, which is applied to the aforementioned browser-based WASM printing plug-in method, and the system includes: An acquisition unit, used for acquiring a wasm binary file to obtain a wasm plug-in, wherein the wasm binary file can be recognized by a browser; A loading unit, used to deploy the wasm plug-in to a web server and obtain a wasm plug-in address, wherein the wasm plug-in address represents an address of the wasm plug-in in the web server; A download unit, used to download the wasm plug-in at the front end of the browser according to the wasm plug-in address to obtain a wasm instance; The printing unit is used to obtain the incoming document to be printed, and use the function parameter parsing of the function interface of the wasm instance to process and print the document to be printed.
[0015] A third aspect of the present invention provides a computer program, which, when executed by a processor, implements the steps of the aforementioned browser-based WASM printing plug-in method.
[0016] Beneficial effects: The present application provides a browser-based WASM printing plug-in method. First, a wasm binary file is obtained to obtain a wasm plug-in, wherein the wasm binary file can be recognized by the browser; then, the wasm plug-in is deployed to a web server to obtain a wasm plug-in address, wherein the wasm plug-in address represents the address of the wasm plug-in in the web server; next, at the front end of the browser, according to the wasm plug-in address, the wasm plug-in is downloaded to obtain a wasm instance; finally, the incoming document to be printed is obtained, and the function parameter parsing of the function interface of the wasm instance is used to process and print the document to be printed. Using the above method, printing can be performed based on the browser's WASM, which solves the shortcomings of the ActiveX plug-in in terms of adaptation. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the conventional technology, the drawings required for use in the embodiments or the conventional technology descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 It is a flowchart of a browser-based WASM printing plug-in method in one embodiment; Figure 2 A print plug-in architecture diagram of a browser-based WASM print plug-in method in one embodiment; Figure 3 A framework diagram of a browser-based WASM printing plug-in method in one embodiment; Figure 4 The functional diagram of a browser-based WASM printing plug-in method in one embodiment. DETAILED DESCRIPTION
[0019] In order to facilitate understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. Embodiments of the present application are provided in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used herein includes any and all couplings of one or more related listed items.
[0021] It can be understood that the terms "first", "second", etc. used in the present application can be used in this article to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from another element.
[0022] Some terms involved in this application are explained below to facilitate understanding of this application: WASM, WebAssembly is a binary instruction format that can be used as a compilation target for programming languages such as C, C++, Rust, etc. It is designed for efficient execution and can run in modern browsers. WASM has performance close to native code, so it is suitable for applications that require high-performance computing, such as games, image processing, scientific computing, etc.
[0023] Emscripten compiler is an open source compiler toolchain that is mainly used to compile C and C++ code into WebAssembly (WASM) or asm.js so that these codes can be run in web browsers. The emcc command is the main compiler driver in the Emscripten toolchain, similar to gcc or clang, and is used to compile C and C++ code into WebAssembly (WASM) or asm.js The fetch method is a modern JavaScript API for making asynchronous HTTP requests on the network. It is used to replace the old XMLHttpRequest, providing more powerful and flexible functions, and a simpler syntax.
[0024] The get method refers to a request method used in the HTTP protocol to request resources on the server.
[0025] The front end refers to the local computer that interacts with the user.
[0026] The backend, which is the server-side part of the application, is responsible for processing data, business logic, and interaction with the database.
[0027] Within the current technical scope, the browser printing function is limited by traditional means. Users need to rely on the built-in printing interface of the browser or the print dialog box provided by the operating system to perform operations. This process has certain limitations in functionality, user experience design and scalability.
[0028] In addition, business functions can only be completed through the browser's own print dialog box, which has a single function. It cannot adapt to some special business scenarios, such as silent printing on self-service devices. It is even more impossible to achieve refined management of printing. For security reasons, the browser does not allow js (javascript) to directly access peripheral hardware devices. This makes it impossible to customize and develop the printing function, and it is not scalable.
[0029] With the rise of WASM (WebAssembly) technology, it has become possible to use high-performance languages such as C++ in the browser to directly interact with the printer, achieving refined control and all-round monitoring of the printer.
[0030] In view of this, the present application provides a browser-based WASM printing plug-in method, which proposes to encapsulate the printing function into a WASM module plug-in, and then solve the printing of the self-service device by calling the WASM module function in the browser. The present invention is not only cross-platform, but also runs in the browser, and has the characteristics of high efficiency, convenience and speed. Commonly used browsers can already support WASM (WebAssembly), which solves the shortcomings of ActiveX plug-ins in terms of adaptation.
[0031] In addition, the print plug-in has the feature of self-identification when printing PDF files, without the need to install any PDF reader. It has the functions of simple deployment and refined control of printing to meet specific self-service printing needs.
[0032] A first aspect of the present invention provides a browser-based WASM printing plug-in method, the method comprising: like Figures 1 to 4 As shown, S100 obtains the wasm binary file and obtains the wasm plug-in.
[0033] The wasm binary file can be recognized by the browser.
[0034] Specifically, the source code file is compiled into the printer.wasm binary file using the emcc command of the Emscripten compiler, wherein the export functions of the printer.wasm binary file include three function interfaces, namely malloc, free and print_cmd. Furthermore, malloc is a dynamic memory allocation function interface, free is a dynamic memory release function interface and print_cmd is a print command execution function interface, wherein the print command execution function interface includes at least a print service type and a print service parameter. When the printer.wasm binary file is used, malloc is used as a dynamic memory allocation function interface for memory allocation, and after the printer.wasm binary file is used, free is used as a dynamic memory release function interface for memory release, thereby ensuring the reasonable use of memory.
[0035] For example, print_cmd can have two parameters: cmdtype print service type: 0-- print service, 1-- print control service. cmdparam print service parameter: json string format, including print attribute parameters and remote print document address parameters.
[0036] S200, deploy the wasm plug-in to the web server and obtain the wasm plug-in address.
[0037] The wasm plug-in address represents the address of the wasm plug-in in the web server.
[0038] Specifically, getting the wasm plugin address includes the following steps: Obtain the web server that supports static file hosting.
[0039] Store the wasm plug-in in the web server directory to obtain the wasm plug-in address.
[0040] It should be noted that the web server can choose a server that supports static file hosting. The advantage of this is that the static file hosting server is used to efficiently provide static resources (such as HTML, CSS, JavaScript, images, WASM files, etc.) without having to deal with dynamic content generation. In other words, files can be transferred with minimal overhead and delay to ensure that users can load pages quickly. In addition, it is relatively simple to deploy a static file hosting web server. You only need to place the file in a specified directory, and the configuration requirements are relatively low. This convenience allows developers to quickly set up and launch applications, which is suitable for scenarios that require rapid deployment. It can also reduce the complexity and potential failure points on the server side, making the system more reliable and stable.
[0041] S300, at the front end of the browser, download the wasm plug-in according to the wasm plug-in address to obtain a wasm instance.
[0042] Specifically, JavaScript language is used in the browser front end, and the wasm plug-in is downloaded using the fetch method according to the wasm plug-in address to obtain a wasm instance, wherein the wasm instance represents instantiation of binary data into a wasm instance.
[0043] It should be noted that through JavaScript, wasm modules can be easily introduced into existing web browser applications to achieve code interoperability. JavaScript can call functions in wasm modules, and wasm can also call JavaScript functions, thus achieving seamless collaboration between the two.
[0044] On the browser front end, the purpose of obtaining a WebAssembly (WASM) instance through JavaScript is to be able to load, initialize, and call functions in the wasm plug-in. This step is a key part of the WebAssembly workflow because it converts binary WASM files into instance objects that can be called by JavaScript, allowing JavaScript and wasm to interoperate. The wasm file is a compiled binary file that needs to be loaded and parsed by the browser. In JavaScript, the wasm file can be parsed into an executable WebAssembly plug-in. Thus, the wasm function is realized. After obtaining the wasm instance, you can access and call the functions exported in the wasm plug-in through the instance object. These functions are specified at compile time, such as the dynamic memory allocation function interface, the dynamic memory release function interface, and the execution print command function interface. Through the instance object, JavaScript can directly call these functions and obtain the return value. After obtaining the wasm instance, you can flexibly control the execution of the wasm plug-in in JavaScript. JavaScript can call functions in wasm, pass parameters, and obtain results, and vice versa. This interoperability makes it possible to combine high-performance wasm plugins with flexible JavaScript logic in web applications.
[0045] S400, obtaining the incoming document to be printed, and using the function parameter parsing of the function interface of the wasm instance to process and print the document to be printed.
[0046] Specifically, S400 includes the following steps: According to the input document to be printed, the input business type and the input business parameters input by the front end are obtained; wherein the input business type indicates the type of the document to be printed, and the input business parameters indicate the relevant parameters of the document to be printed; Determining the printing service type according to the incoming service type; According to the printing service type and the corresponding printing service parameters, the input service parameters are parsed to obtain the server address of the document to be printed; According to the server address, the document to be printed is downloaded to the local computer, and the processing result returned by the service is obtained; The success or failure of the processing is determined based on the processing result returned by the service.
[0047] It should be noted that, according to the document to be printed transmitted by the front end, the corresponding incoming business type and incoming business parameters can be obtained. That is to say, the incoming business type identifies the operation to be performed on the document to be printed, such as monitoring, tracking, controlling and printing, etc. The business parameters belong to the next level of the business type, that is, after the business type is determined, the corresponding business parameters can be formed according to the business type. For example, after determining the incoming business type, according to the incoming business type, the corresponding print business type cmdtype in the print_cmd function interface can be called, and then the print business parameter cmdparam corresponding to the print business type cmdtype is used to parse the incoming business parameters to obtain the required specific parameters. For another example, the print business parameter cmdparam is used to parse the function parameters of the incoming business parameters, and the parameters are parsed to the remote printing document address parameters, that is, the server address of the document to be printed; then, according to the server address, the document to be printed can be downloaded to the local computer, so as to obtain the successful processing result returned by the business, otherwise the processing result returned by the business fails. The returned processing result is success or failure. The returned processing result can be returned to the front end and / or the back end. If it is returned to the back end, it is convenient for subsequent computer engineers to understand the cause of the failure; if it is returned to the front end, it is convenient for the operator to understand the processing progress immediately, so as to reprocess or change the processing method, etc.
[0048] It should also be noted that the step of downloading the document to be printed to the local computer according to the server address and obtaining the processing result returned by the service includes: Utilizing the printing service parameters, the input service parameters are parsed to obtain the server address fileurl of the document to be printed; According to the server address fileurl of the document to be printed, calling the get method of http to download the document to be printed to the local computer; Then, the printing service parameters are used to parse the input service parameters to obtain the required number of printing sheets; Compare the required number of printing papers with the number of remaining papers in the printing paper box to obtain a comparison result; If the comparison result is that the number of remaining papers is greater than or equal to the number of printing papers, a print instruction is generated; otherwise, a processing failure instruction is generated.
[0049] Specifically, the printing service parameters are used to parse the incoming service parameters. Parsing means using a function to calculate, thereby obtaining the server address fileurl of the document to be printed, calling the get method of http to download the print document to the local computer. Further, JavaScript is used to call the get method of HTTP in the browser environment to download the print document, which can be achieved through the fetch API (fetch API is a JavaScript API used to make HTTP requests, mainly used to obtain resources from the network, making asynchronous operations more concise and easy to read). Next, according to the windows operating system of the local computer, the status of the default printer is obtained through the spool api (print spooler API, used to manage print jobs and printers); when the operating system of the local computer is linux, the status of the default printer is obtained on linux through lpstat (lpstat is a command used to display the printer status on Linux and other Unix-like systems) to determine whether the printing status is normal. Then, the printing service parameters are used again to parse the incoming service parameters to obtain the number of printed sheets. That is to say, the number of pages is included in the incoming service parameters, so that the required number of sheets can be parsed. The required number of sheets of paper is compared with the number of sheets of paper currently in the printing paper box. If the number of sheets of paper remaining in the printing paper box is greater than or equal to the number of sheets required to be printed, a printing instruction is generated and sent to the printer. Otherwise, a processing failure instruction is generated and returned to the front end or back end as needed.
[0050] It should also be noted that the step of reusing the printing service parameters to parse the input service parameters to obtain the required number of printing sheets includes: Determining the format of the document to be printed according to the binary byte identifier of the document to be printed that is input; If the format of the document to be printed is a PDF file, the document to be printed is parsed to determine the number of pages of the document to be printed; According to the number of printed pages of the pdf file, the printed documents are sent to the printer in sequence; If the format of the document to be printed is a picture, determining the number of pages of the document to be printed; If the format of the document to be printed is not a picture, converting the document to be printed into a picture, and determining the number of pages of the document to be printed; The printed documents are sent to the printer in sequence according to the number of printed pages of the picture.
[0051] Specifically, when processing a document to be printed, especially when transmitting the document to be printed over a network, the document to be printed will be transmitted and processed in the form of binary data. Among them, the binary byte identifier is to represent the data of the document to be printed as a series of byte streams. In this way, according to the binary byte identifier of the incoming document to be printed, the bytes of the format part are identified to determine the format of the document to be printed. If the format of the binary byte representation of the document to be printed is a pdf file, the document to be printed is parsed to obtain the number of pages of the document to be printed. Next, according to the number of pages, the pages are sent to the printer page by page in the order of the pdf file for printing. If the format of the binary byte representation of the document to be printed is a picture, it is sent directly to the printer for printing according to the order; if the format of the binary byte representation of the document to be printed is non-picture, such as text, the text is converted into a picture and sent to the printer for printing according to the order.
[0052] In the steps of sequentially sending the printed documents to the printer according to the number of printed pages of the PDF file, and sequentially sending the printed documents to the printer according to the number of printed pages of the picture, the following steps are also included before the step of sequentially sending the printed documents to the printer: Using the printing service parameters, the input service parameters are parsed to obtain the printing attributes of each page of the PDF file or picture; wherein the printing attributes at least include paper direction, paper size and paper box position; The printing attribute is set by using the interface of the operating system, and a PDF file or picture with the printing attribute is obtained accordingly; Send the pdf file or image with printing properties to the printer.
[0053] It should be noted that in the above steps, before sending the content to be printed to the printer, it is necessary to parse the attributes of each page, that is, use the printing business parameters to parse the incoming business parameters, and after parsing, the printing attributes of each page of the PDF file or picture can be obtained. When sending each page of the PDF file or picture to the printer, the printing attributes of each page are also sent to the printer, so that the printer can print the corresponding PDF file or picture according to the printing attributes.
[0054] Print plug-in calling process implementation example Step 1: Deploy the compiled printer.wasm plugin to the web server.
[0055] Step 2: The browser front-end javascript downloads printer.wasm through the fetch method.
[0056] const resp = await fetch(printerwasmurl); Where printerwasmurl is the printer.wasm address of the remote server.
[0057] Step 3: The browser front-end javascript obtains the wasm instance.
[0058] const bytes = await resp.arrayBuffer(); const prntinst= await WebAssembly.instantiate(bytes, { env: {}, }); Step 4: The browser front-end javascript obtains the function interface through the instance.
[0059] constret=prntinst.exports.print_cmd(cmdtype,wasmcmdstr); in cmdtype: The incoming business type passed in by the front end.
[0060] cmdparamstr: The incoming business parameters in json format passed in by the front end wasmcmdstr : The conversion of cmdparamstr string passed in by front-end js. The specific conversion is as follows: const wasmcmdstr = prntinst.exports.malloc(cmdparamstr.length); const HEAP8 = new Int8Array(prntinst.exports.memory.buffer); cmdparamstr.split('').forEach((char, index) =>{ HEAP8[(wasmcmdstr + index)>>0] = char.charCodeAt(0); }); ret : The processing result returned by the business. 0 if successful, otherwise failed.
[0061] Step 5: Release the wasm module resources prntinst.exports.free(wasmcmdstr); Printing Service Example Step 1: Parse the incoming business parameters to obtain the server address fileurl of the document to be printed. Call the http get method to download the document to be printed to the local computer.
[0062] Step 2: The Windows operating system obtains the status of the default printer through the spool API, and the Linux operating system obtains the status of the default printer through lpstat to determine whether the printing status is normal.
[0063] Step 3: parse the incoming business parameters again to get the capacity of the printing paper box, and determine whether there is enough paper based on the number of printed papers saved locally.
[0064] Step 4: Parse the document to be printed and identify whether it is a PDF file based on the binary byte identifier of the document to be printed.
[0065] If it is a PDF file, parse the PDF file and identify how many pages need to be printed. Before sending each page of print content to the printer in a loop, parse the print attributes of each page according to the incoming business parameters, including paper direction (horizontal or vertical), paper size (a3 or a4), paper box position, etc. Set the print attributes through the operating system interface. After setting the print attributes, send the content of the current page to the printer. This realizes the function of refined printing.
[0066] Step 5: If the document to be printed is not a picture, such as text, call the corresponding conversion process to convert it into a jpg picture.
[0067] Step 6: If the document to be printed is a picture, set the paper size, orientation, paper tray position, etc. according to the printing properties of the incoming business parameters, and then send the picture content to the printer.
[0068] Step 7: According to the number of print copies passed in as business parameters, loop through steps 4 to 6 above.
[0069] Step 8: Feedback the printing results to the front end.
[0070] Print control service implementation example Controls the pause and resume of the print queue.
[0071] Step 1: Parse the incoming business parameters to determine whether to pause or continue the task.
[0072] Step 2: If it is paused, call the Windows spool API or lpstat to obtain the print queue of the default printer, detect the status of the print queue, and set the pause status of the print queue.
[0073] Step 3: If you want to continue execution, set the execution status of the print queue.
[0074] A second aspect of the present invention provides a browser-based WASM printing plug-in system, which is applied to the aforementioned browser-based WASM printing plug-in method, and the system includes: An acquisition unit, used for acquiring a wasm binary file to obtain a wasm plug-in, wherein the wasm binary file can be recognized by a browser; A loading unit, used to deploy the wasm plug-in to a web server and obtain a wasm plug-in address, wherein the wasm plug-in address represents an address of the wasm plug-in in the web server; A download unit, used to download the wasm plug-in at the front end of the browser according to the wasm plug-in address to obtain a wasm instance; The printing unit is used to obtain the incoming document to be printed, and use the function parameter parsing of the function interface of the wasm instance to process and print the document to be printed.
[0075] A third aspect of the present invention provides a computer program, which, when executed by a processor, implements the steps of the aforementioned browser-based WASM printing plug-in method.
[0076] In summary, this application provides a browser-based WASM printing plug-in method, and the printing plug-in mainly supports pictures and PDFs for printing content. Especially for PDF, the printing plug-in has the characteristics of self-identification when printing PDF files, and there is no need to install any PDF reader. Not only does it meet the basic printing functions, but it also realizes the personalized setting of printing properties for each page of PDF, realizing personalized printing in a true sense. It has the functions of simple deployment and refined control of printing, so as to meet specific self-service printing needs.
[0077] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0078] The various embodiments in the present disclosure are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
[0079] The protection scope of the present disclosure is not limited to the above-mentioned embodiments. Obviously, those skilled in the art can make various changes and modifications to the present disclosure without departing from the scope and spirit of the present disclosure. If these changes and modifications fall within the scope of the claims of the present disclosure and their equivalents, the intention of the present disclosure also includes these changes and modifications.
Claims
1. A browser-based WASM printing plug-in method, It is characterized in that Methods include: Obtain a wasm binary file and obtain a wasm plug-in, wherein the wasm binary file can be recognized by the browser; Deploy the wasm plug-in to a web server to obtain a wasm plug-in address, wherein the wasm plug-in address represents the address of the wasm plug-in in the web server; At the front end of the browser, according to the wasm plug-in address, the wasm plug-in is downloaded to obtain a wasm instance; Get the incoming document to be printed, and use the function parameter parsing of the function interface of the wasm instance to process and print the document to be printed.
2. The browser-based WASM printing plug-in method according to claim 1, It is characterized in that The step of obtaining the wasm binary file and obtaining the wasm plug-in includes: The source code file is compiled into a printer.wasm binary file using the emcc command of the Emscripten compiler, wherein the export function of the printer.wasm binary file includes a dynamic memory allocation function interface, a dynamic memory release function interface, and a print command execution function interface, wherein the print command execution function interface includes at least a print service type and a print service parameter.
3. The browser-based WASM printing plug-in method according to claim 1, It is characterized in that The step of deploying the wasm plug-in to the web server and obtaining the wasm plug-in address includes: Obtain the web server that supports static file hosting; Store the wasm plug-in in the web server directory to obtain the wasm plug-in address.
4. The browser-based WASM printing plug-in method according to claim 1, It is characterized in that The step of downloading the wasm plug-in address at the front end of the browser to obtain the wasm instance includes: JavaScript language is used in the browser front end, and the wasm plug-in is downloaded using the fetch method according to the wasm plug-in address to obtain a wasm instance, wherein the wasm instance represents instantiation of binary data into a wasm instance.
5. The browser-based WASM printing plug-in method according to claim 2, It is characterized in that The step of obtaining the incoming document to be printed, and using the function parameter parsing of the function interface of the wasm instance to process and print the document to be printed includes: According to the input document to be printed, obtaining the input business type and the input business parameters input by the front end, wherein the input business type indicates the type of the document to be printed, and the input business parameters indicate the relevant parameters of the document to be printed; Determining the printing service type according to the incoming service type; According to the printing service type and the corresponding printing service parameters, the input service parameters are parsed to obtain the server address of the document to be printed; According to the server address, the document to be printed is downloaded to the local computer, and the processing result returned by the service is obtained; The success or failure of the processing is determined based on the processing result returned by the service.
6. The browser-based WASM printing plug-in method according to claim 5, It is characterized in that The step of downloading the document to be printed to the local computer according to the server address and obtaining the processing result returned by the service comprises: Utilizing the printing service parameters, the input service parameters are parsed to obtain the server address fileurl of the document to be printed; According to the server address fileurl of the document to be printed, calling the get method of http to download the document to be printed to the local computer; Then, the printing service parameters are used to parse the input service parameters to obtain the required number of printing sheets; Compare the required number of printing papers with the number of remaining papers in the printing paper box to obtain a comparison result; If the comparison result is that the number of remaining papers is greater than or equal to the number of printing papers, a print instruction is generated; otherwise, a processing failure instruction is generated.
7. The browser-based WASM printing plug-in method according to claim 6, It is characterized in that The step of reusing the printing service parameters to parse the input service parameters to obtain the required number of printing sheets includes: Determining the format of the document to be printed according to the binary byte identifier of the document to be printed that is input; If the format of the document to be printed is a PDF file, the document to be printed is parsed to determine the number of pages of the document to be printed; According to the number of printed pages of the pdf file, the printed documents are sent to the printer in sequence; If the format of the document to be printed is a picture, determining the number of pages of the document to be printed; If the format of the document to be printed is not a picture, converting the document to be printed into a picture, and determining the number of pages of the document to be printed; The printed documents are sent to the printer in sequence according to the number of printed pages of the picture.
8. The browser-based WASM printing plug-in method according to claim 7, It is characterized in that The steps of sequentially sending the printed documents to the printer according to the number of printed pages of the PDF file, and sequentially sending the printed documents to the printer according to the number of printed pages of the picture, both include: Before the step of sending the print document to the printer in sequence: Using the printing service parameters, the input service parameters are parsed to obtain the printing attributes of each page of the PDF file or picture, wherein the printing attributes at least include paper direction, paper size and paper box position; The printing attribute is set by using the interface of the operating system, and a PDF file or picture with the printing attribute is obtained accordingly; Send the pdf file or image with printing properties to the printer.
9. A browser-based WASM printing plug-in system, It is characterized in that The browser-based WASM printing plug-in method applied to any one of claims 1-8, the system comprising: An acquisition unit, used for acquiring a wasm binary file to obtain a wasm plug-in, wherein the wasm binary file can be recognized by a browser; A loading unit, used to deploy the wasm plug-in to a web server and obtain a wasm plug-in address, wherein the wasm plug-in address represents an address of the wasm plug-in in the web server; A download unit, used to download the wasm plug-in at the front end of the browser according to the wasm plug-in address to obtain a wasm instance; The printing unit is used to obtain the incoming document to be printed, and use the function parameter parsing of the function interface of the wasm instance to process and print the document to be printed.
10. A computer program, It is characterized in that When the computer program is executed by a processor, the steps of the browser-based WASM printing plug-in method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Webpage printing method based on analysis plug-in, server and storage medium
CN110837347A
Cross-browser accurate printing implementation method capable of being designed by user
CN116204140A
Front-end printing method and device based on WEB browser
CN116719493A
Information processing apparatus and control method thereof, and non-transitory computer-readable storage medium
US20230161527A1
Customizing forms based upon parameters in a template
WO2001084299A1
