Printing method and system
By automatically recognizing the browser's print content configuration information, and customizing or globally configuring the layout for printing, the problem of browser printing being unable to freely control text format and poor quality is solved, enabling users to customize print effects and optimize resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CORELAND
- Filing Date
- 2022-07-14
- Publication Date
- 2026-06-26
Smart Images

Figure CN115167790B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more specifically, to a printing method and system. Background Technology
[0002] The demand for printing in browsers is increasing. For example, websites providing online retail services need to print orders directly on the website, and businesses need to print online forms. Currently, one way is to use the browser's built-in window.print() method and custom printing CSS controls to print the target information. Another way is to generate templates through code, such as PDF format, and print them by previewing them in the browser.
[0003] The above-mentioned printing methods using the browser's built-in features have drawbacks, including a lack of control over text formatting and poor print quality. The method of generating templates through code, where developers pre-set print templates during development, often fails to meet user needs. Summary of the Invention
[0004] In view of the above problems, the purpose of this application is to provide a printing method and system that automatically identifies the configuration information of the content to be printed; specifically, if the configuration information includes a custom print template, it prints according to the custom print template; if the configuration information does not contain a custom print template, it automatically typesets and prints according to the custom configuration or global configuration as required. The printing method provided by this application automatically identifies the content to be printed and automatically typesets and prints it according to the configuration items and table format, which meets the user's needs for customizing print configuration and print layout, and can present better printing results.
[0005] In a first aspect, embodiments of this application provide a printing method for browser printing. The printing method includes: reading printing configuration information; wherein the printing configuration information includes a target printing template and / or a target printing configuration; determining whether the target printing configuration information includes a custom printing template; if the target printing template does not include a custom printing template, obtaining a document object model corresponding to the target printing content; filtering the document object model to obtain a filtered document object model; rearranging the filtered document object model to generate a target document object model; and converting the target document object model into a target printing format according to the target printing configuration, and printing.
[0006] In the above implementation process, if the configuration information includes a custom print template, it will print according to the custom print template; if the configuration information does not include a custom print template, it will print according to the custom configuration or the global configuration as required, automatically formatting the print. This achieves automated recognition of configuration information, which can maximize the satisfaction of users' print layout needs and produce better printing results.
[0007] Optionally, in this embodiment of the application, before reading the print configuration information, the printing method further includes: determining whether the print configuration information includes a custom print template; if the print configuration information does not include a custom print template, determining whether the print configuration information includes custom configuration information; if the print configuration information includes custom configuration information, merging the custom configuration information and the global configuration information; and generating a target print configuration based on the merged custom configuration information and the global configuration information.
[0008] In the above implementation process, it first determines whether the print configuration information includes a custom print template; if not, it determines whether the configuration information includes custom configuration information; if so, it merges the custom configuration information with the global configuration information and generates the target print configuration. This achieves automatic identification of custom print configuration information and custom print templates, and merges the custom print configuration with the global configuration to obtain the target print configuration, thus including user-defined information in the target configuration.
[0009] Optionally, in this embodiment of the application, if the print configuration information does not include custom configuration information, the target print configuration is generated based on the global configuration information.
[0010] In the above implementation process, if the print configuration information does not include custom configuration information, the global configuration information is used directly, and the global configuration information is identified as the target print configuration; the target print configuration is used to print the target content; thus, the printing method provided in this application embodiment can also print directly when the user has not made any configuration modifications.
[0011] Optionally, in this embodiment of the application, if the print configuration information includes a custom print template, then the target print template is generated based on the custom print template.
[0012] In the above implementation process, if a custom print template is included in the configuration information, it is directly identified as the target print destination. The custom template may have been generated by the user in a previous print job; if the user's custom printing needs remain unchanged, this custom print template can be used directly for printing. This avoids repetitive configuration and improves reusability.
[0013] Optionally, in this embodiment, rearranging the filtered document object model to generate the target document object model includes: obtaining the document object model corresponding to the target print content; calculating the parent-child relationship between the document object model and the filtered document object model; and adding the filtered document object model according to the proportion of the document object model container to generate the target document object model.
[0014] In the above implementation process, the filtered document object models are rearranged. This is because rearranging the document object models would disrupt the previous order, affecting the printing format. The parent-child relationships of the document object models are recalculated to generate new target object document models. This avoids document object model corruption and printing format issues that would result from changes to the printing configuration.
[0015] Optionally, in this embodiment of the application, converting the target document object model into the target printing format according to the target printing configuration includes: performing text attribute transformation on the target document object model according to the target printing configuration to generate the target printing format; wherein, the text attribute transformation includes transformation of text font and text format.
[0016] In the above implementation process, the text attributes of the target document object model are transformed according to the target printing configuration to generate the target printing format; this target printing format represents the target printing configuration, and can be used directly for printing when printing is triggered.
[0017] Optionally, in this embodiment of the application, filtering the document object model includes: obtaining elements in the document object model that are ignored from printing; wherein, the elements that are ignored from printing include elements in the document object model with a value of 0.
[0018] In the above implementation process, there is some information in the printed content that does not need to be printed, such as empty tables; this information needs to be filtered out. This information consists of elements with a value of 0 in the document object model, thereby avoiding the waste of printing resources.
[0019] Secondly, embodiments of this application provide a printing system for browser printing. The printing system includes: a printing configuration acquisition module, a target document object model generation module, and a printing module. The printing configuration acquisition module is used to read the target printing template from the printing configuration information. The target document object model generation module is used to determine whether the target printing template includes a custom printing template. If the target printing template does not include a custom printing template, the module acquires the document object model corresponding to the target printing content; filters the document object model to obtain a filtered document object model; rearranges the filtered document object model to generate the target document object model; and the printing module converts the target document object model into a target printing format according to the target printing configuration and prints it.
[0020] Thirdly, embodiments of this application provide an electronic device, which includes a memory and a processor. The memory stores program instructions, and when the processor reads and runs the program instructions, it executes the steps in any of the above implementation methods.
[0021] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer program instructions, which, when read and executed by a processor, perform the steps in any of the above implementations. Attached Figure Description
[0022] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments of this application will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 A first printing flowchart provided for embodiments of this application;
[0024] Figure 2 A flowchart for generating the target printing configuration provided in this application embodiment;
[0025] Figure 3 A flowchart illustrating the generation process of the target document object model provided in this application embodiment;
[0026] Figure 4 A second printing flowchart provided for embodiments of this application;
[0027] Figure 5 A third printing flowchart provided for embodiments of this application;
[0028] Figure 6 A schematic diagram of a printing system module provided in an embodiment of this application;
[0029] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0030] The technical solutions of the embodiments of this application will now be described with reference to the accompanying drawings. For example, the flowcharts and block diagrams in the drawings illustrate the architecture, functions, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram may represent a module, program segment, or part of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions. In addition, the functional modules in the various embodiments of the present invention may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0031] During the research process, the applicant discovered that web browsing and access via a browser often involves printing needs, including various requirements such as 1:1 printing of the original page, partial printing, and adaptive layout printing. Currently, one approach is to use the browser's built-in `window.print()` method and custom printing CSS controls to print the target information; another approach is to generate templates using code, such as PDF format, and then preview and print them in the browser. However, printing using the browser's built-in methods suffers from limitations in controlling text formatting and poor print quality. The method of generating templates using code often results in developers pre-setting print templates during development, which frequently fails to meet user needs.
[0032] Based on this, the printing method provided in this application can automatically identify the content to be printed and automatically format and print it according to the configuration items and table method, which meets the user's needs for customizing printing configuration and printing layout, and can present a better printing effect.
[0033] Please refer to Figure 1 , Figure 1 A first printing flowchart is provided for an embodiment of this application; the printing method includes:
[0034] Step S100: Read the print configuration information.
[0035] In step S100 above, the print configuration information is read. It should be noted that the print configuration information may contain a target print template or a target print configuration. The target print template can be used directly for printing; the target print configuration needs to be rendered into a print template for printing.
[0036] Step S102: Determine whether the target print configuration information includes a custom print template.
[0037] In step S102 above, it is determined whether the target print configuration information includes a custom print template; the purpose of this determination is that if a custom print template exists, it can be used directly for printing.
[0038] Step S103: If the target print template does not include a custom print template, then obtain the document object model corresponding to the target print content.
[0039] If the custom print template is not included in step S103 above, it means that a print template needs to be generated; it is understood that the print template can be generated using the target print configuration.
[0040] Step S104: Filter the document object model to obtain the filtered document object model.
[0041] In step S104 above, the parts of the document that do not need to be printed are filtered out, and the filtered document object model is obtained after filtering.
[0042] Step S105: Rearrange the filtered document object model to generate the target document object model.
[0043] In step S105 above, filtering may cause the document object model to become disordered, making it impossible to achieve a good printing effect. Therefore, it is rearranged to obtain a new document object model.
[0044] Step S106: Convert the target document object model into the target printing format according to the target printing configuration, and print it.
[0045] In step S106 above, the final generated document object model is converted into the target printing format, which enables printing.
[0046] pass Figure 1 It can be seen that if the configuration information includes a custom print template, the print will be executed according to the custom print template; if the configuration information does not include a custom print template, the print will be automatically formatted and printed according to the custom configuration or global configuration as required. This achieves automated recognition of configuration information, which can maximize the satisfaction of users' print layout needs and produce better printing results.
[0047] Please refer to Figure 2 , Figure 2 A flowchart for generating a target printing configuration test provided in this application embodiment; the method includes:
[0048] Step S200: Determine whether the print configuration information includes a custom print template.
[0049] In step S200 above, it is first determined whether the print configuration information includes a custom print template;
[0050] Step S201: If the print configuration information does not include a custom print template, then determine whether the print configuration information includes custom configuration information.
[0051] In step S201 above, if the print configuration information does not include a custom print template, it is further determined whether the print configuration information includes custom configuration information.
[0052] Step S202: If the printed configuration information includes custom configuration information, then merge the custom configuration information and the global configuration information.
[0053] In step S202 above, if the printed configuration information includes custom configuration information, the custom configuration information is merged with the global configuration information. Since there is a lot of printed configuration information, the user may only change part of the configuration. The unchanged part can continue to use the original global configuration.
[0054] Step S203: Generate the target print configuration based on the merged custom configuration information and global configuration information.
[0055] In step S203 above, the merged custom configuration information and global configuration information can generate the target printing configuration.
[0056] pass Figure 2 It can be seen that the system first determines whether the print configuration information includes a custom print template; if not, it determines whether the configuration information includes custom configuration information; if so, it merges the custom configuration information with the global configuration information to generate the target print configuration. This achieves automatic identification of custom print configuration information and custom print templates, and merges the custom print configuration with the global configuration to obtain the target print configuration, thus including user-defined information in the target configuration.
[0057] In an optional embodiment, if the print configuration information does not include custom configuration information, the target print configuration is generated based on the global configuration information. That is, when there is no custom template and no custom configuration information, the global configuration is directly used as the target print configuration.
[0058] Therefore, if the print configuration information does not include custom configuration information, the global configuration information is used directly, and the global configuration information is identified as the target print configuration; the target print configuration is used to print the target content; thus, the printing method provided in this application embodiment can also print directly when the user has not made any configuration modifications.
[0059] In an optional embodiment, if the print configuration information includes a custom print template, the target print template is generated based on the custom print template. That is, if a custom print template exists in the print configuration information, it is used directly for printing.
[0060] Therefore, if a custom print template is included in the configuration information, it will be directly identified as the target print job. This custom template may have been generated by the user during a previous print job; if the user's custom printing needs remain unchanged, this template can be used directly for printing. This avoids redundant configuration and improves reusability.
[0061] Please see Figure 3 , Figure 3 A flowchart for generating a target document object model is provided in this application embodiment; the method includes:
[0062] Step S300: Obtain the document object model corresponding to the target print content.
[0063] In step S300 above, the document object model corresponding to the target print content is obtained. It should be understood that the document object model here is the original document object model.
[0064] Step S301: Calculate the parent-child relationship between the document object model and the filtered document object model.
[0065] In step S301 above, the filtered document object model is judged based on the target printing configuration from the following dimensions: whether it is a parent document object model, whether the tag is displayed, whether it has a value, etc., to determine whether the corresponding document object model should be displayed and whether the previous style display needs to be retained. Finally, it is determined whether the corresponding proportion needs to be recalculated; it can be understood that if the target printing configuration is generated by the global configuration, the container proportion does not need to be recalculated; if the target printing configuration is a combination of custom configuration and global configuration, the container proportion needs to be recalculated. After the judgment is completed, the parent-child relationship of the document object models before and after filtering is converted.
[0066] Step S302: Add the filtered document object model according to the proportion of the document object model container to generate the target document object model.
[0067] In step S301 above, the filtered document object model is added based on the proportion of the document object model container. For example, the corresponding document object model proportion judgment is configured in the configuration class to identify the document object model selector that needs to be calculated for proportion judgment; if no configuration is provided, it is automatically calculated based on the item items under the form, which is the proportion of the current item under a row, converted to a fraction (such as 1 / 2, 1 / 3); thereby obtaining the target document object model.
[0068] Depend on Figure 3 It is evident that the filtered document object model is rearranged; the reason is that rearranging the document object model would disrupt the previous order, affecting the printing format. The parent-child relationships of the document object models are recalculated to generate a new target object document model. This avoids document object model corruption and printing format issues that would result from changes to the printing configuration.
[0069] In an optional embodiment, converting the target document object model into a target printing format according to the target printing configuration includes: performing text attribute transformation on the target document object model according to the target printing configuration to generate the target printing format; wherein, the text attribute transformation includes transformation of text font and text format. For example, after obtaining the target document object model, target document object model tree rendering is performed. It can be understood that rendering is converting the content to be printed into the target printing format corresponding to the target configuration according to the target printing configuration. Further, if the target printing content is displayed in a table format, then when splitting rows and columns, if the container ratio of the target printing content document object model is 1, it occupies a single row; if the container ratio of the target printing content document object model is 1 / 2, it occupies half the number of columns in a row, and rows and columns are automatically merged. It should be noted that if there are filtering items in the configuration, a filtering annotation is added before this target document object model, and it is registered in the user-configured printing style registry on the new page rendering, allowing user-defined styles to be overridden after the default printing style registry.
[0070] Therefore, the text attributes of the target document object model are transformed according to the target printing configuration to generate the target printing format; this target printing format represents the target printing configuration, and can be used directly for printing when printing is triggered.
[0071] In an optional embodiment, filtering the document object model includes: obtaining elements in the document object model that are ignored from printing; wherein, elements that are ignored from printing include elements in the document object model with a value of 0. In the printed content, there is some information that does not need to be printed, such as empty tables; this information needs to be filtered out, as these are elements with a value of 0 in the document object model, thereby avoiding waste of printing resources.
[0072] Please see Figure 4 , Figure 4 A second printing flowchart provided for embodiments of this application. The method includes:
[0073] Step S400: Load the print page in the browser.
[0074] Step S401: Read the software toolkit, which may be an SDK; it is understood that an SDK is a software development kit; the toolkit used in this application is an SDK, but in actual applications, software toolkits are intended to achieve custom configurations, and SDK should not be a limitation on the type of software toolkit in this application.
[0075] Step S402: Read configuration information. The configuration information may include the target print template and / or the target print configuration. It should be noted that the target print template is generated from a custom print template. The target print configuration may be a global configuration or a combination of global configuration and custom configuration.
[0076] Step S403: Determine whether a custom template exists in the configuration information.
[0077] Step S404: If a custom template exists, load the template to generate the target print template; prepare for printing.
[0078] Step S405: If there is no custom template in the configuration information, determine whether there is a custom configuration.
[0079] Step S406: If there is a custom configuration in the configuration information, merge the custom configuration information with the global configuration information to generate the target configuration.
[0080] Step S407: If custom configuration information exists in the configuration information, then the global configuration information will be used as the target configuration.
[0081] Step S408: Convert the target print configuration into a target print template.
[0082] Step S409: Bind a page event listener; if printing is triggered, it will be listened to.
[0083] Step S410: Pop up the printout.
[0084] This completes a full printing process. During the process, the content to be printed is automatically identified and formatted according to the configuration items and table format, which meets the user's needs for customizing print configuration and print layout, and can present good print results.
[0085] Please check Figure 5 , Figure 5A third printing flowchart provided for embodiments of this application; the method includes:
[0086] Step S500: Read the original document object model tree.
[0087] In step S500 above, the original document object model tree is read from the target printing configuration; it can be understood that the original document object model tree corresponds to the document object model before the custom configuration was performed.
[0088] Step S501: Calculate the parent-child relationship between the document object model and the filtered document object model to obtain the target document object model.
[0089] In step S501 above, the filtered document object model is judged based on the target printing configuration from the following dimensions: whether it is a parent document object model, whether the tag is displayed, whether it has a value, etc., to determine whether the corresponding document object model should be displayed and whether the previous style display needs to be retained. Finally, it is determined whether the corresponding proportion needs to be recalculated; it can be understood that if the target printing configuration is generated by the global configuration, the container proportion does not need to be recalculated; if the target printing configuration is a combination of custom configuration and global configuration, the container proportion needs to be recalculated. After the judgment is completed, the parent-child relationship of the document object models before and after filtering is converted.
[0090] Step S502: Add the target document object model to the corresponding attribute of each document object model according to the proportion of the new container.
[0091] Step S503: Determine whether the target document object model conforms to the table item format.
[0092] Step S504: If the format is correct, convert the target document object model to the target printing format according to the table entry format and print it. Step S505: If the target document object model does not conform to the table entry format, perform document transformation on the target document object model to obtain the table entry format.
[0093] Step S506: Start printing.
[0094] pass Figure 5 It is evident that if the order of the document object model is disrupted, the printing format will be affected. The parent-child relationships of the document object model are recalculated to generate a new target object document model. This avoids document object model corruption and printing format issues caused by changes to the printing configuration. In practical applications, if table-style printing is required, the target document object model is transformed to achieve table-style printing.
[0095] Please check Figure 6 , Figure 6This is a schematic diagram of a printing system module provided in an embodiment of this application; the printing system 500 includes: a printing configuration acquisition module 501, a target document object model generation module 502, and a printing module 503.
[0096] The print configuration acquisition module 501 is used to read the target print template from the print configuration information.
[0097] The target document object model generation module 502 is used to determine whether the target print template includes a custom print template; if the target print template does not include a custom print template, the document object model corresponding to the target print content is obtained; the document object model is filtered to obtain a filtered document object model; and the filtered document object model is rearranged to generate the target document object model.
[0098] The printing module 503 is used to convert the target document object model into the target printing format according to the target printing configuration and then print it.
[0099] In an optional embodiment, before the print configuration acquisition module 501 reads the print configuration information, the printing method further includes: the print configuration acquisition module 501 determining whether the print configuration information includes a custom print template; if the print configuration information does not include a custom print template, determining whether the print configuration information includes custom configuration information; if the print configuration information includes custom configuration information, merging the custom configuration information and the global configuration information; and the print configuration acquisition module 501 generating a target print configuration based on the merged custom configuration information and the global configuration information.
[0100] In an optional embodiment, if the print configuration information does not include custom configuration information, the print configuration acquisition module 501 generates the target print configuration based on the global configuration information.
[0101] In an optional embodiment, if the print configuration information includes a custom print template, the print configuration acquisition module 501 generates a target print template based on the custom print template.
[0102] In an optional embodiment, the target document object model generation module 502 rearranges the filtered document object model to generate the target document object model, including: the target document object model generation module 502 obtains the document object model corresponding to the target print content; calculates the parent-child relationship between the document object model and the filtered document object model; and the target document object model generation module 502 adds the filtered document object model according to the proportion of the document object model container to generate the target document object model.
[0103] In an optional embodiment, the printing module 503 converts the target document object model into a target printing format according to the target printing configuration, which includes: the printing module 503 performing text attribute transformation on the target document object model according to the target printing configuration to generate the target printing format; wherein, the text attribute transformation includes transformation of text font and text format.
[0104] In an optional embodiment, the target document object model generation module 502 filters the document object model by: obtaining elements with a value of 0 in the document object model; wherein, elements with a value of 0 represent elements that are ignored for printing; and deleting elements with a value of 0 from the document object model.
[0105] Please see Figure 7 , Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. An electronic device 600 provided in this application includes: a processor 601 and a memory 602. The memory 602 stores machine-readable instructions executable by the processor 602. When the machine-readable instructions are executed by the processor 602, the method described above is performed.
[0106] Based on the same inventive concept, embodiments of this application also provide a computer-readable storage medium storing computer program instructions, which, when read and executed by a processor, perform the steps in any of the above implementations.
[0107] The computer-readable storage medium can be any medium capable of storing program code, such as Random Access Memory (RAM), Read Only Memory (ROM), Programmable Read-Only Memory (PROM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM). The storage medium stores the program, and the processor executes the program after receiving an execution instruction. The method executed by the electronic terminal as defined in any embodiment of this invention can be applied to the processor or implemented by the processor.
[0108] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0109] Furthermore, the units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0110] Furthermore, the functional modules in the various embodiments of this application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0111] It can be replaced and can be implemented, wholly or partially, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, wholly or partially, in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated.
[0112] The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0113] In this document, relational terms such as "first" and "second" are used merely to distinguish one entity or operation from another, without necessarily requiring or implying any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes said element.
[0114] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of protection of this application.
Claims
1. A printing method, characterized in that, The printing method is used for browser printing, and the method includes: Read print configuration information; wherein, the print configuration information includes the target print template and / or the target print configuration; Determine whether the print configuration information includes a custom print template; If the custom print template is not included in the print configuration information, then obtain the document object model corresponding to the target print content; Filter the document object model to obtain a filtered document object model; The filtered document object model is rearranged to generate the target document object model; and The target document object model is converted into the target printing format according to the target printing configuration, and then printed. The rearrangement of the filtered document object model to generate the target document object model includes: Obtain the document object model corresponding to the target print content; Convert the parent-child relationship between the document object model and the filtered document object model; The filtered document object model is added according to the proportion of the document object model container to generate the target document object model; The filtering of the document object model includes: Obtain the elements in the document object model that are ignored from printing; wherein, the elements that are ignored from printing include elements in the document object model with a value of 0; Remove the element that was supposed to be ignored from the document object model; Prior to reading the print configuration information, the method further includes: Determine whether the print configuration information includes a custom print template; If the print configuration information does not include the custom print template, then determine whether the print configuration information includes custom configuration information; If the print configuration information includes the custom configuration information, then the custom configuration information and the global configuration information are merged. The target printing configuration is generated based on the merged custom configuration information and the global configuration information. The method further includes: If the print configuration information includes the custom print template, then the target print template is generated based on the custom print template.
2. The method according to claim 1, characterized in that, The method further includes: If the custom configuration information is not included in the print configuration information, then the target print configuration is generated based on the global configuration information.
3. The method according to claim 1, characterized in that, The step of converting the target document object model into the target printing format according to the target printing configuration includes: The target document object model is subjected to text attribute transformation according to the target printing configuration to generate the target printing format; wherein, the text attribute transformation includes transformation of text font and text format.
4. A printing system, characterized in that, The printing system is used for browser printing, and the printing system includes: a printing configuration acquisition module, a target document object model generation module, and a printing module; The print configuration acquisition module is used to read the target print template from the print configuration information; The target document object model generation module is used to determine whether the target print template includes a custom print template; if the target print template does not include a custom print template, then the document object model corresponding to the target print content is obtained; the document object model is filtered to obtain a filtered document object model; and the filtered document object model is rearranged to generate the target document object model; and The printing module is used to convert the target document object model into the target printing format according to the target printing configuration, and then print it. The target document object model generation module is further configured to: obtain the document object model corresponding to the target print content; calculate the parent-child relationship between the document object model and the filtered document object model; and add the filtered document object model according to the proportion of the document object model container to generate the target document object model. The filtering of the document object model includes: Obtain the elements in the document object model that are ignored from printing; wherein, the elements that are ignored from printing include elements in the document object model with a value of 0; delete the elements that are ignored from printing from the document object model; The print configuration acquisition module is further configured to: Determine whether the print configuration information includes a custom print template; If the print configuration information does not include the custom print template, then determine whether the print configuration information includes custom configuration information; If the print configuration information includes the custom configuration information, then the custom configuration information and the global configuration information are merged. The target printing configuration is generated based on the merged custom configuration information and the global configuration information. If the print configuration information includes the custom print template, then the target print template is generated based on the custom print template.
5. An electronic device, characterized in that, The electronic device includes a memory and a processor. The memory stores program instructions, and when the processor executes the program instructions, it performs the steps of the method according to any one of claims 1-3.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processor, perform the steps of the method according to any one of claims 1-3.