A printing method, device and equipment based on binary data

By parsing data type and font library binarization of the printed content, the problem of the binarization effects of characters and pictures in traditional printing methods affecting each other, achieving better printing effects.

CN115145501BActive Publication Date: 2025-09-02BEIJING BAIGEFEICHI TECH LLC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110352812.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-31
Publication Date
2025-09-02
Estimated Expiration
2041-03-31

AI Technical Summary

Technical Problem

When traditional printing methods deal with mixed content of pictures and texts, the binarization effects of text and pictures affect each other, resulting in uneven strokes of text and jagged problems.

Method used

By obtaining the data type analysis of the content to be printed, the corresponding binary processing is performed using the font library, and the combination is combined and typesetting is generated in the original order.

Benefits of technology

It realizes uniform strokes of text and formula content, without jagging, and improves printing quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115145501B_ABST
    Figure CN115145501B_ABST
Patent Text Reader

Abstract

The present invention discloses a printing method based on binary data, the method comprising: obtaining content to be printed and parsing the data type of the content to be printed, wherein the data type includes one or more of a text type, a formula type, and an image type; performing corresponding binarization processing on different data types based on a font library to obtain corresponding initial binary images; merging and typeset the initial binary images according to the original order of the content to be printed to obtain a binary image; and outputting the binary image, converting it into print data for printing. The method can achieve better printing processing effects while ensuring that the text content is not affected by the image, so that the text or formula content in the output binary image has uniform strokes and no jagged edges.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of intelligent devices, and in particular to a printing method, apparatus and device based on binary data. Background Art

[0002] Traditional printing involves typeset layout first, followed by overall binarization, and then printing. Existing printing methods primarily involve taking a screenshot of the content to be printed, scaling the screenshot image to the printer's width, and finally binarizing and printing it. However, using screenshots requires subsequent processing of the image itself. Printing ultimately requires processing the image into a binary image, and the binarization effect ultimately affects the quality of the printed content. For example, in mixed text and graphics printouts, binarization must consider both the text and image binarization effects, and these effects often affect each other, resulting in jagged text. Taking screenshots often changes the grayscale variation at the edges of text, and scaling the image also changes the font weight. Ultimately, binarization may result in some strokes being thicker and some being thinner within the same character. Summary of the Invention

[0003] In view of this, the present invention provides a printing method, device and equipment based on binary data, which can at least effectively solve the above problems, so as to first obtain binary data of different contents and then re-layout and print according to the original layout.

[0004] To achieve the above object, the present invention provides a printing method based on binary data, the method comprising:

[0005] Acquire content to be printed, and parse the data type of the content to be printed, wherein the data type includes one or more of a text type, a formula type, and an image type;

[0006] Performing corresponding binarization processing on different data types based on the character library to obtain corresponding initial binarized images;

[0007] Merging and typeset the initial binary images according to the original order of the contents to be printed to obtain a binary image;

[0008] The binary image is output for display or converted into print data and sent to a printer for printing.

[0009] Optionally, the content to be printed is stored in a database in HTML data format.

[0010] Optionally, the step of parsing the data type of the content to be printed includes:

[0011] The data type of the content to be printed is parsed using different HTML tags, wherein the HTML tags include text tags, formula tags, and image tags.

[0012] Optionally, the step of performing corresponding binarization processing on different data types based on the character library to obtain corresponding initial binarized images includes:

[0013] When the data type is a text type, the initial binary image of the text is obtained by obtaining the corresponding binary data of the text in the character library and replacing the data according to the order of the text in the content to be printed.

[0014] Optionally, the step of performing corresponding binarization processing on different data types based on the character library to obtain corresponding initial binarized images includes:

[0015] When the data type is a formula type, after parsing the formula in the content to be printed using a formula parser, the corresponding digital symbol binary data in the font library is obtained and replaced according to the formula rules in the content to be printed to obtain a complete formula initial binary image.

[0016] Optionally, the step of performing corresponding binarization processing on different data types based on the character library to obtain corresponding initial binarized images includes:

[0017] When the data type is an image type, the image type is determined to be a pure text image. If so, after performing OCR recognition, the corresponding text binarization data in the font library is obtained, and the text is replaced according to the order of the text in the content to be printed to obtain an initial binarized image of the text; otherwise, the image type in the content to be printed is processed using error diffusion binarization to obtain an initial binarized image.

[0018] Optionally, the step of merging and typeset-ing the initial binary images according to the original order of the contents to be printed to obtain a binary image includes:

[0019] Generate a white background image based on the preset maximum width;

[0020] All the initial binary images are merged and arranged and overlaid in the white background image according to the original order of the content to be printed, so as to obtain a binary image similar to the content to be printed.

[0021] To achieve the above object, the present invention further provides a printing device based on binary data, the device comprising:

[0022] an acquiring unit, configured to acquire content to be printed and parse the content to be printed for data type, wherein the data type includes one or more of a text type, a formula type, and an image type;

[0023] a processing unit, configured to perform corresponding binarization processing on different data types based on a character library to obtain corresponding initial binarized images;

[0024] a typesetting unit, configured to merge and typeset the initial binary images according to the original order of the contents to be printed, to obtain a binary image;

[0025] The output unit is used to output the binary image and convert it into print data for printing.

[0026] To achieve the above-mentioned objectives, the present invention also provides a printing device based on binary data, comprising a processor, a memory, and a computer program stored in the memory, wherein the computer program can be executed by the processor to implement a printing method based on binary data as described in the above-mentioned embodiment.

[0027] Beneficial effects:

[0028] The printing method, device and equipment based on binary data provided by the present invention obtain the content to be printed and parse the data type to distinguish different types in the content to be printed and perform corresponding binarization processing. After replacing it with a font library, the corresponding initial binary image is obtained and then rearranged, which can achieve better printing processing effects. At the same time, it ensures that the text content is not affected by the image, so that the text or formula content of the output binary image has uniform strokes and no jagged edges. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0030] Figure 1 A schematic flow chart of a printing method based on binary data provided by one embodiment of the present invention.

[0031] Figure 2 A flowchart of an embodiment of the present invention is provided.

[0032] Figure 3 A schematic diagram of a binarized image result provided by an embodiment of the present invention.

[0033] Figure 4 A schematic structural diagram of a printing device based on binary data provided by one embodiment of the present invention.

[0034] The realization of the objectives of the invention, the functional features and advantages will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention for which protection is sought, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0036] The present invention is described in detail below with reference to the following embodiments. To facilitate understanding by those skilled in the art, the present invention is described in further detail with reference to the following embodiments and the accompanying drawings.

[0037] The present invention provides a printing method based on binary data, which can achieve better printing processing effect and ensure that the text content is not affected by the image, so that the text or formula content of the output binary image has uniform strokes and no jaggedness.

[0038] Example 1:

[0039] Please refer to Figures 1 to 3 A first embodiment of the present invention provides a printing method based on binary data, which can be executed by a printing device based on binary data, and in particular, by one or more processors within the printing device based on binary data, and includes at least the following steps:

[0040] An embodiment of the present invention provides a printing method based on binary data, comprising:

[0041] S11, obtaining content to be printed, and parsing the data type of the content to be printed, wherein the data type includes one or more of a text type, a formula type, and an image type.

[0042] The content to be printed is stored in the database in HTML format.

[0043] The step of analyzing the data type of the content to be printed includes:

[0044] The data type of the content to be printed is parsed using different HTML tags, wherein the HTML tags include text tags, formula tags, and image tags.

[0045] In this embodiment, the obtained content to be printed is stored in the database as HTML data, and is parsed in the order in which the content to be printed exists, specifically using different HTML tags to parse the content to be printed, so as to separate the data types such as text, formula and image in the content to be printed. The content to be printed includes at least one of the above data types. Among them, text tags and image tags are generally represented by the symbol "<>", while formula tags are generally represented by the symbol "$$". The content between two $$ is the formula content, such as: ${x}^{2}-2x+m=0$, which means x 2 -2x+m=0. For example, the text label has 、 、 、 、 、 、 、 、 <strong>、< / strong> 、 、 、 、 、 <center> 、< / center> 、 、 etc.; image tags have ,wait.

[0046] S12, performing corresponding binarization processing on the different data types based on the font library to obtain corresponding initial binarized images.

[0047] In this embodiment, the font library is an electronic text font collection library of foreign fonts, Chinese fonts, and related characters. It is the image source for displaying Chinese characters, letters, punctuation marks, mathematical symbols, etc. when we use a computer. When the computer calls the font library to display Chinese characters, it does not directly call the same image, but instead calls the internal code of the Chinese character. The program uses this internal code to search the corresponding image source (font library) for the corresponding image information to display on the screen or print on paper. The font library can be a system-provided font library or other custom font library, which is not limited here.

[0048] The step of performing corresponding binarization processing on different data types based on the font library to obtain corresponding initial binarized images includes:

[0049] (1) When the data type is text type, the corresponding text binary data in the font library is obtained and replaced according to the order of the text in the content to be printed to obtain an initial binary image of the text.

[0050] (2) When the data type is a formula type, after parsing the formula in the content to be printed using a formula parser, the corresponding digital symbol binary data in the font library is obtained and replaced according to the formula rules in the content to be printed to obtain a complete formula initial binary image.

[0051] (3) When the data type is an image type, determine whether the image type is a plain text image. If so, perform OCR recognition, obtain the corresponding text binarization data in the font library, and replace it according to the order of the text in the content to be printed to obtain an initial binarized image of the text; otherwise, use error diffusion binarization to process the image type in the content to be printed to obtain an initial binarized image.

[0052] S13, merging and typeset the initial binary images according to the original order of the contents to be printed to obtain a binary image.

[0053] S14, outputting the binary image, converting it into print data for printing.

[0054] The step of merging and typeset-ing the initial binary images according to the original order of the contents to be printed to obtain a binary image comprises:

[0055] S14-1, generating a white background image according to a preset maximum width;

[0056] S14-2, merging all the initial binary images, and arranging and overlaying them in the white background image according to the original order of the content to be printed, so as to obtain a binary image similar to the content to be printed.

[0057] For the sake of convenience, the following example is given. By obtaining the content to be printed (hereinafter referred to as the obtained title HTML data) and parsing the data type, different types of content to be printed are distinguished and corresponding binary processing is performed. After matching and replacing using the font library, the corresponding initial binary image is obtained, and then the binary image close to the content to be printed is obtained by re-layout rendering for display or printing. The corresponding result screenshot can be referred to Figure 3 As shown. Figure 3 It can be clearly seen that the text and formula content in the displayed result graph have uniform strokes and no jagged edges, which can achieve better printing effects.

[0058] <!DOCTYPEhtml>

[0059] <meta charset="UTF-8"> <title> Title< / title> <link href="https: mb-mm-s.oss-cn-shanghai.aliyuncs.com appweb math_styles mathSt yles_f523c83.css"rel="stylesheet"> <link rel="stylesheet"href="https: cdn.jsdelivr.net npm bootstrap@3.3.7 dist css bootstrap.min.css"integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz K68vbdEjh4u"crossorigin="anonymous"><scriptsrc="https: / / cdn.bootcdn.net / ajax / libs / jquery / 3.5.1 / jquery.js"> <script src="https: cdn.jsdelivr.net npm bootstrap@3.3.7 dist js bootstrap.min.js"integrity="sha384-tc5iqib027qvyjsmfhjomalkfuwvxzxupncja7l2mcwnip g9mgcd8wgnicpd7txa"crossorigin="anonymous">< / script> <scriptsrc="https: / / mb-mm-s.oss-cn-shanghai.aliyuncs.com / appweb / mathjax_274 / MathJa x.js?config=update190725-1"> It is known that the equation ${x}^{2}-2x+m=0$ about $x$ has two unequal real roots ${x}_{1}$ and ${x}_{2}$. (1) Find the range of values ​​of the real number $m$; (2) If ${x}_{1}-{x}_{2}=2$, find the value of the real number $m$. Answer (1) From the question, we can get: $\Delta={\left(-2\right)}^{2}-4\times 1\times m=4-4m\gt 0$ The solution is: $m\lt 1$ That is, the range of the real number $m$ is $m\lt 1$ (2) From the relationship between roots and coefficients, we can get: ${x}_{1}+{x}_{2}=2$ That is, $\left\{\begin{array}{l}{x}_{1}+{x}_{2}=2\\{x}_{1}-{x}_{2}=2\end{array}\right.$ The solution is: ${x}_{1}=2$, ${x}_{2}=0$ From the relationship between roots and coefficients, we can get: $m=2\times 0=0$ <scriptsrc="https: / / mb-mm-s.oss-cn-shanghai.aliyuncs.com / appweb / mathjax_274 / MathJa x.js?config=update190725-1"> <script>function renderLatex(){MathJax.Hub.Queue([function(){console.log("body:"+document.body);console.log(`开始转换:${Date.now()}`);}],['Typeset',MathJax.Hub,document.body],[function(){document.body.classList.remove('hide');rendering=false;console.log('renderfinish');console.log(`转换完成:${Date.now()}`);}]);}renderLatex();< / script>

[0060] Example 2:

[0061] Reference Figure 4 FIG2 is a schematic structural diagram of a printing device based on binary data provided by an embodiment of the present invention.

[0062] In this embodiment, the device 40 includes:

[0063] An acquiring unit 41 is configured to acquire content to be printed and parse the content to be printed for data type, wherein the data type includes one or more of a text type, a formula type, and an image type;

[0064] A processing unit 42 is configured to perform corresponding binarization processing on different data types based on a character library to obtain corresponding initial binarized images;

[0065] a typesetting unit 43 configured to merge and typeset the initial binary images according to the original order of the contents to be printed to obtain a binary image;

[0066] The output unit 44 is used to output the binary image and convert it into print data for printing.

[0067] Furthermore, the content to be printed is stored in a database in HTML format.

[0068] Furthermore, the acquiring unit 41 is specifically configured to:

[0069] The data parsing unit is used to parse the data type of the content to be printed using different HTML tags, wherein the HTML tags include text tags, formula tags and image tags.

[0070] Furthermore, the processing unit 42 is specifically configured to:

[0071] The text processing unit is used for obtaining the corresponding binary data of the text in the font library when the data type is text type, and replacing the data according to the order of the text in the content to be printed to obtain an initial binary image of the text.

[0072] Furthermore, the processing unit 42 is further configured to:

[0073] A formula processing unit is used to parse the formula in the content to be printed using a formula parser when the data type is a formula type, obtain the corresponding digital symbol binary data in the font library, and replace it according to the formula rules in the content to be printed to obtain a complete formula initial binary image.

[0074] Furthermore, the processing unit 42 is further configured to:

[0075] An image processing unit is used to determine whether the image type is a plain text image when the data type is an image type. If so, after performing OCR recognition, obtain the corresponding text binarization data in the font library, and replace the text according to the order of the text in the content to be printed to obtain an initial binarized image of the text; otherwise, use error diffusion binarization to process the image type in the content to be printed to obtain an initial binarized image.

[0076] Furthermore, the typesetting unit 43 is specifically configured to:

[0077] A background generation unit, configured to generate a white background image according to a preset maximum width;

[0078] The typesetting and overlaying unit is used to merge all the initial binary images and arrange and overlay them in the white background image according to the original order of the content to be printed, so as to obtain a binary image similar to the content to be printed.

[0079] Each unit module of the device 40 can respectively execute the corresponding steps in the above method embodiment, so each unit module will not be described in detail here. Please refer to the description of the corresponding steps above for details.

[0080] An embodiment of the present invention further provides a printing device based on binary data, comprising a processor, a memory, and a computer program stored in the memory, wherein the computer program can be executed by the processor to implement the printing method based on binary data as described in the above embodiment.

[0081] The binary data-based printing device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that the schematic diagram is merely an example of a binary data-based printing device and does not limit the scope of binary data-based printing devices. Binary data-based printing devices may include more or fewer components than shown, or may combine certain components or have different components. For example, the binary data-based printing device may also include input / output devices, network access devices, buses, and the like.

[0082] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor. The control center of the binary data-based printing device connects various parts of the entire binary data-based printing device using various interfaces and lines.

[0083] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the binary data-based printing device by running or executing the computer program and / or module stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.); the data storage area can store data created based on the use of the mobile phone (such as audio data, a phone book, etc.). In addition, the memory can include a high-speed random access memory and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage device.

[0084] Wherein, if the unit integrated into the printing device based on binary data is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention can implement all or part of the processes in the above-mentioned embodiment method by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of each of the above-mentioned method embodiments. Wherein, the computer program includes computer program code, which can be in source code form, object code form, executable file, or some intermediate form.

[0085] It should be noted that the device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed across multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. In addition, in the drawings of the device embodiments provided by the present invention, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines. A person of ordinary skill in the art can understand and implement the present invention without inventive work.

[0086] The implementation schemes in the above embodiments can be further combined or replaced, and the embodiments are merely descriptions of optional embodiments of the present invention, and do not limit the concept and scope of the present invention. Without departing from the design concept of the present invention, various changes and improvements made to the technical solutions of the present invention by professional and technical personnel in this field shall fall within the scope of protection of the present invention.

Claims

1. A printing method based on binary data, characterized in that: The method comprises: Acquire content to be printed, and parse the data type of the content to be printed, wherein the data type obtained by the parsing includes one or more of a text type, a formula type, and an image type; performing corresponding binarization processing on the to-be-printed contents of different data types based on the font library to obtain corresponding initial binarized images; Merging and typeset the initial binary images according to the original order of the contents to be printed to obtain a binary image; The binary image is output and converted into print data for printing.

2. The printing method based on binary data according to claim 1, characterized in that: The content to be printed is stored in a database in HTML format.

3. The printing method based on binary data according to claim 1, characterized in that: The step of analyzing the data type of the content to be printed includes: The data type of the content to be printed is parsed using different HTML tags, wherein the HTML tags include text tags, formula tags, and image tags.

4. The printing method based on binary data according to claim 1, characterized in that: The step of performing corresponding binarization processing on the to-be-printed contents of different data types based on the font library to obtain corresponding initial binarized images includes: When the data type is a text type, the initial binary image of the text is obtained by obtaining the corresponding binary data of the text in the character library and replacing the data according to the order of the text in the content to be printed.

5. The printing method based on binary data according to claim 1, characterized in that: The step of performing corresponding binarization processing on the to-be-printed contents of different data types based on the font library to obtain corresponding initial binarized images includes: When the data type is a formula type, after parsing the formula in the content to be printed using a formula parser, the corresponding digital symbol binary data in the font library is obtained and replaced according to the formula rules in the content to be printed to obtain a complete formula initial binary image.

6. The printing method based on binary data according to claim 1, characterized in that: The step of performing corresponding binarization processing on the to-be-printed contents of different data types based on the font library to obtain corresponding initial binarized images includes: When the data type is an image type, the image type is determined to be a pure text image. If so, after performing OCR recognition, the corresponding text binarization data in the font library is obtained, and the text is replaced according to the order of the text in the content to be printed to obtain an initial binarized image of the text; otherwise, the image type in the content to be printed is processed using error diffusion binarization to obtain an initial binarized image.

7. The printing method based on binary data according to claim 1, characterized in that: The step of merging and typeset-ing the initial binary images according to the original order of the contents to be printed to obtain a binary image comprises: Generate a white background image based on the preset maximum width; All the initial binary images are merged and arranged and overlaid in the white background image according to the original order of the content to be printed, so as to obtain a binary image similar to the content to be printed.

8. A printing device based on binary data, characterized in that: The device comprises: an acquiring unit, configured to acquire content to be printed and parse the data type of the content to be printed, wherein the data type obtained by the parsing includes one or more of a text type, a formula type, and an image type; a processing unit, configured to perform corresponding binarization processing on the to-be-printed contents of different data types based on a font library to obtain corresponding initial binarized images; a typesetting unit, configured to merge and typeset the initial binary images according to the original order of the contents to be printed, to obtain a binary image; The output unit is used to output the binary image and convert it into print data for printing.

9. A printing device based on binary data, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory, wherein the computer program can be executed by the processor to implement a printing method based on binary data according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Printing method and printing system for micro printer

    CN102591603A

  • Realization method for cross-platform high-speed thermal printer on intelligent terminal

    CN107885465A