Print data restoration method and device and electronic equipment
By analyzing and hash matching the printed data, and determining the restored font information, the problem of poor restoration effect of printing file data is solved, and more accurate restoration of complex images and special fonts is achieved.
Patent Information
- Application Number
- CN202411385992.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-30
- Publication Date
- 2025-02-14
AI Technical Summary
In the prior art, the data restoration effect of printing files is poor, especially for complex images and special fonts.
By acquiring the print data, the enhanced metafile information is obtained, the font features are extracted and hashing is performed, and the standard hash value that matches the preset is determined to determine the restored font information, thereby determining the restored print data.
Improves the data restoration effect of printed files and can restore complex images and special fonts more accurately.
Smart Images

Figure CN119440433A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of printing technology, and in particular to a printing data restoration method, device and electronic equipment. Background Art
[0002] Currently, you need to use the driver acquisition function of the software bridge to capture print files. This function installs a virtual printer driver and dumps the print task into a file on the computer instead of actually outputting it to the printer. In this way, you can get a print file containing vector information, including images and text content.
[0003] For such printed files, image processing and text recognition technologies can be used to restore them. Image processing technology can help us extract and process image elements in printed files, including adjusting image size, enhancing clarity, color correction, etc. Text recognition technology can convert text content in printed files into editable text form. However, the restoration of image and text content may be limited by the quality of the printed file itself, such as low resolution, distortion or damage, and it is not always possible to perfectly restore the printed file, especially for complex images and special fonts.
[0004] In general, the data restoration effect of current printed documents is poor. Summary of the invention
[0005] The object of the present invention is to provide a method, device and electronic device for restoring printed data, so as to alleviate the technical problem of poor data restoration effect of current printed files and improve the data restoration effect of printed files.
[0006] In a first aspect, an embodiment of the present invention provides a method for restoring print data, comprising: acquiring print data; parsing the print data to obtain enhanced metafile information; extracting font features from the enhanced metafile information; performing a hash operation on the font features to obtain a hash value; matching the hash value with a preset standard hash value to obtain matched font information; the standard hash value is pre-parsed based on preset standard font features; and determining the restored print data based on the matched font information and the enhanced metafile information.
[0007] In a preferred embodiment of the present invention, the enhanced metafile information includes: vector graphics, text content and font information in the above-mentioned printing data; the step of extracting font features from the above-mentioned enhanced metafile information includes: extracting font features from the above-mentioned font information; the step of determining the restored printing data based on the above-mentioned matched font information and the above-mentioned enhanced metafile information includes: determining the restored printing data based on the above-mentioned matched font information, the above-mentioned vector graphics and text content.
[0008] In a preferred embodiment of the present invention, the step of determining the restored printing data based on the above-mentioned matched font information, the above-mentioned vector graphics and the text content includes: determining the restored text content based on the above-mentioned matched font information and the text content; determining the restored printing data based on the above-mentioned original text content and the above-mentioned vector graphics.
[0009] In a preferred embodiment of the present invention, the types of the above-mentioned vector graphics include: straight lines, curves and polygons.
[0010] In a preferred embodiment of the present invention, the step of matching the above-mentioned hash value with a preset standard hash value to obtain matched font information includes: matching the above-mentioned hash value with a preset standard hash value to obtain a target character arrangement order, a target font style and a target font size corresponding to the above-mentioned hash value; and determining the above-mentioned target character arrangement order, target font style and target font size as the above-mentioned matched font information.
[0011] In a preferred embodiment of the present invention, the number of the above-mentioned font features is multiple; after the step of extracting the font features from the above-mentioned enhanced metafile information, the above-mentioned method also includes: arranging the above-mentioned font features in series according to a preset order to obtain the arranged font features; the step of performing a hash operation on the above-mentioned font features to obtain a hash value includes: performing a hash operation on the above-mentioned arranged font features to obtain a hash value.
[0012] In a preferred embodiment of the present invention, after the step of determining the restored print data based on the matched font information and the enhanced metafile information, the method further includes: obtaining updated font feature information supplemented by the user; determining an updated standard hash value based on the updated font feature information; matching the hash value with the updated standard hash value to obtain updated font information; and determining updated print data based on the updated font information and the enhanced metafile information.
[0013] In a second aspect, an embodiment of the present invention further provides a print data restoration device, comprising: a data acquisition module, used to acquire print data; a data parsing module, used to parse the print data to obtain enhanced metafile information; a feature extraction module, used to extract font features from the enhanced metafile information; a hash calculation module, used to perform a hash operation on the font features to obtain a hash value; a font matching module, used to match the hash value with a preset standard hash value to obtain matched font information; the standard hash value is pre-obtained based on a preset standard font feature analysis; a data restoration module, used to determine the restored print data based on the matched font information and the enhanced metafile information.
[0014] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the print data restoration method.
[0015] In a fourth aspect, an embodiment of the present invention further provides a computer storage medium, characterized in that the computer storage medium stores a computer program, the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the print data restoration method.
[0016] The embodiment of the present invention provides a method, device and electronic device for restoring printing data, including: obtaining printing data; parsing the printing data to obtain enhanced metafile information; extracting font features from the enhanced metafile information; performing hash operation on the font features to obtain a hash value; matching the hash value with a preset standard hash value to obtain matched font information; the standard hash value is pre-parsed based on preset standard font features; and determining restored printing data based on the matched font information and the enhanced metafile information. The method parses the printing data, performs hash calculation based on the data, and matches the hash value with the standard to determine the restored printing data, thereby improving the data restoration effect of the printing file. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1A schematic flow chart of a printing data restoration method provided by an embodiment of the present invention;
[0019] Figure 2 A schematic flow chart of another printing data restoration method provided by an embodiment of the present invention;
[0020] Figure 3 A schematic diagram of the structure of a printing data restoration device provided by an embodiment of the present invention;
[0021] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention.
[0022] Icons: 31 - data acquisition module; 32 - data analysis module; 33 - feature extraction module; 34 - hash calculation module; 35 - font matching module; 36 - data restoration module; 41 - processor; 42 - memory; 43 - bus; 44 - communication interface. DETAILED DESCRIPTION
[0023] 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. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0024] For such printed files, image processing and text recognition technologies can be used to restore them. Image processing technology can help us extract and process image elements in printed files, including adjusting image size, clarity enhancement, color correction, etc. Text recognition technology can convert the text content in printed files into editable text form. However, the restoration of image and text content may be limited by the quality of the printed files themselves, such as low resolution, distortion or damage, and it is not always possible to perfectly restore the printed files, especially for complex images and special fonts. Overall, the data restoration effect of current printed files is poor.
[0025] Based on this, the embodiments of the present invention provide a method, device and electronic device for restoring printed data, which can improve the data restoration effect of printed files. For ease of understanding, the above-mentioned method for restoring printed data is first introduced in detail.
[0026] Example 1
[0027] In this embodiment, Figure 1 A schematic flow chart of a printing data restoration method provided by an embodiment of the present invention.
[0028] Depend on Figure 1As can be seen, the method includes:
[0029] Step S101: Obtain printing data.
[0030] In this embodiment, the above S101 specifically includes the following when implemented: first, obtaining print data with vector information from the print service. This can be achieved by collecting print service data on the Windows operating system. Using the API or other related tools provided by the Windows operating system, data can be collected from the print service. These data include metadata of the print task, printer configuration information, and the content of the print file. Through this step, detailed information about each print task can be obtained, including the printer name, paper size, print quality settings, etc. The print data is usually stored in the print pool, and its original file can be obtained by setting "Keep original document" in the printer driver, which is usually stored in binary format.
[0031] Step S102: parsing the above printing data to obtain enhanced metafile information.
[0032] Here, the enhanced metafile information is a graphic representation format based on Windows GDI (Graphics Device Interface), which is stored in binary form and includes a series of GDI function calls and parameters for describing the graphic content in the print data.
[0033] Step S103: extracting font features from the enhanced metafile information.
[0034] In this embodiment, when parsing the enhanced metafile information, records related to fonts can be obtained, such as selecting fonts, setting font attributes, etc. By parsing these records, font information used in the print file can be extracted, including font features such as font name, font style (such as bold, italic), and font size.
[0035] Step S104: performing a hash operation on the above-mentioned font features to obtain a hash value.
[0036] Step S105: Match the above hash value with a preset standard hash value to obtain matched font information; the above standard hash value is obtained in advance based on a preset standard font feature analysis.
[0037] Step S106: Determine restored print data according to the matched font information and the enhanced metafile information.
[0038] The embodiment of the present invention provides a method for restoring printing data, comprising: obtaining printing data; parsing the printing data to obtain enhanced metafile information; extracting font features from the enhanced metafile information; performing hash operation on the font features to obtain a hash value; matching the hash value with a preset standard hash value to obtain matched font information; the standard hash value is pre-parsed based on preset standard font features; and determining restored printing data according to the matched font information and the enhanced metafile information. The method parses the printing data, performs hash calculation based on the data, and matches the hash value with the standard to determine the restored printing data, thereby improving the data restoration effect of the printing file.
[0039] Example 2
[0040] Based on the above embodiments, Figure 2 A schematic flow chart of another printing data restoration method provided by an embodiment of the present invention.
[0041] Depend on Figure 2 As can be seen, the method includes:
[0042] Step S201: Obtain printing data.
[0043] Step S202: parsing the print data to obtain vector graphics, text content and font information in the print data.
[0044] In this embodiment, the vector graphics, text content and font information can be extracted from the enhanced metafile information of the print data. This process can be achieved by parsing EMF records one by one. Each EMF record contains a GDI function call and corresponding parameter values. By parsing the record, the graphics drawing command, coordinate position, color information, etc. can be obtained.
[0045] Furthermore, the types of the above-mentioned vector graphics include: straight lines, curves and polygons.
[0046] Furthermore, the enhanced metafile information also includes records related to text, such as drawing text, selecting fonts, etc. By parsing these records, the text content in the print file can be extracted, and information such as font, font size, and text position can be obtained.
[0047] Step S203: extracting font features from the above font information.
[0048] In actual operation, first of all, it is necessary to identify the font used in the enhanced metafile information. By parsing the "select font" and other related commands in the EMF record, the font name, font style (such as bold, italic) and font size can be obtained.
[0049] Furthermore, for each identified font, its feature information can be extracted, including the font type, font shape, and font weight. The font type refers to the font family, such as Songti, Heiti, etc.; the font shape refers to the appearance of the font, such as normal, italic, etc.; the font weight refers to the thickness of the font, such as normal, bold, etc. This information can be obtained from the font file, usually contained in the metadata of the font file.
[0050] Step S204: performing a hash operation on the above-mentioned font features to obtain a hash value.
[0051] Here, the number of the above-mentioned font features is multiple; after the step of extracting font features from the above-mentioned enhanced metafile information, the above-mentioned method also includes: arranging the above-mentioned font features in series according to a preset order to obtain the arranged font features; the step of performing a hash operation on the above-mentioned font features to obtain a hash value includes: performing a hash operation on the above-mentioned arranged font features to obtain a hash value.
[0052] Step S205: Match the above hash value with a preset standard hash value to obtain matched font information; the above standard hash value is obtained in advance based on a preset standard font feature analysis.
[0053] In this embodiment, the step of matching the above-mentioned hash value with a preset standard hash value to obtain matched font information includes: matching the above-mentioned hash value with a preset standard hash value to obtain a target character arrangement order, a target font style, and a target font size corresponding to the above-mentioned hash value; and determining the above-mentioned target character arrangement order, target font style, and target font size as the above-mentioned matched font information.
[0054] Step S206: Determine the restored print data according to the matched font information, the vector graphics and the text content.
[0055] In actual operation, the step S206 includes: determining the restored text content according to the matched font information and text content; and determining the restored print data according to the original text content and the vector graphics.
[0056] Furthermore, after the step of determining the restored print data based on the matched font information and the enhanced metafile information, the method further includes: obtaining updated font feature information supplemented by the user; determining an updated standard hash value based on the updated font feature information; matching the hash value with the updated standard hash value to obtain updated font information; and determining updated print data based on the updated font information and the enhanced metafile information.
[0057] Furthermore, the font extraction and matching strategies can be adjusted according to different printing qualities to improve the accuracy of text content restoration.
[0058] The embodiment of the present invention provides a method for restoring print data, including: obtaining print data; parsing the print data to obtain vector graphics, text content and font information in the print data; extracting font features from the font information; performing hash operations on the font features to obtain hash values; matching the hash values with preset standard hash values to obtain matched font information; the standard hash values are pre-parsed based on preset standard font features; and determining restored print data based on the matched font information, the vector graphics and text content. The method parses the print data to obtain the corresponding vector graphics, text content and font information, and based on the extracted font features, performs hash calculations and matches them with standard hash values, thereby further improving the data restoration effect of the print file.
[0059] Example 3
[0060] Based on the above embodiments, Figure 3 A schematic diagram of the structure of a print data restoration device provided by an embodiment of the present invention.
[0061] Depend on Figure 3 As can be seen, the device includes:
[0062] The data acquisition module 31 is used to acquire printing data.
[0063] The data analysis module 32 is used to analyze the above printing data to obtain enhanced metafile information.
[0064] The feature extraction module 33 is used to extract font features from the enhanced metafile information.
[0065] The hash calculation module 34 is used to perform a hash operation on the above-mentioned font features to obtain a hash value.
[0066] The font matching module 35 is used to match the above hash value with a preset standard hash value to obtain matched font information; the above standard hash value is obtained in advance based on the preset standard font feature analysis.
[0067] The data restoration module 36 is used to determine the restored printing data according to the matched font information and the enhanced metafile information.
[0068] Among them, the data acquisition module 31, the data analysis module 32, the feature extraction module 33, the hash calculation module 34, the font matching module 35 and the data restoration module 36 are connected in sequence.
[0069] In one embodiment, the enhanced metafile information includes: vector graphics, text content and font information in the above-mentioned printing data; the feature extraction module 33 is also used to extract font features from the above-mentioned font information; the data restoration module 36 is also used to determine the restored printing data based on the above-mentioned matched font information, the above-mentioned vector graphics and text content.
[0070] In one embodiment, the data restoration module 36 is further used to determine the restored text content according to the matched font information and text content; and to determine the restored print data according to the original text content and the vector graphics.
[0071] In one embodiment, the font matching module 35 is also used to match the above-mentioned hash value with a preset standard hash value to obtain the target character arrangement order, target font style and target font size corresponding to the above-mentioned hash value; and determine the above-mentioned target character arrangement order, target font style and target font size as the above-mentioned matched font information.
[0072] In one embodiment, the number of features is multiple; the hash calculation module 34 is also used to arrange the above font features in series according to a preset order to obtain arranged font features; and perform hash operation on the above arranged font features to obtain hash values.
[0073] In one embodiment, the data acquisition module 31 is also used to obtain updated font feature information supplemented by the user; the above-mentioned hash calculation module 34 is also used to determine the updated standard hash value based on the above-mentioned updated font feature information; the above-mentioned font matching module 35 is also used to match the above-mentioned hash value with the updated standard hash value to obtain updated font information; the data restoration module 36 is also used to determine the updated print data based on the above-mentioned updated font information and the above-mentioned enhanced metafile information.
[0074] The implementation principle and technical effects of the print data restoration device provided in the embodiment of the present invention are the same as those of the aforementioned print data restoration method embodiment. For the sake of brief description, for parts not mentioned in the embodiment of the above-mentioned print data restoration device, reference may be made to the corresponding contents in the aforementioned method embodiment.
[0075] The embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it is a schematic diagram of the structure of the electronic device, wherein the electronic device includes a processor 41 and a memory 42, the memory 42 stores machine executable instructions that can be executed by the processor 41, and the processor 41 executes the machine executable instructions to implement the above-mentioned printing data restoration method.
[0076] exist Figure 4 In the illustrated embodiment, the electronic device further includes a bus 43 and a communication interface 44 , wherein the processor 41 , the communication interface 44 and the memory 42 are connected via the bus.
[0077] The memory 42 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk memory. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 44 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus may be an ISA bus, a PCI bus, or an EISA bus, etc. The above-mentioned bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0078] The processor 41 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 41. The above processor 41 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in the embodiments of the present invention can be directly embodied as a hardware decoding processor to be executed, or the hardware and software modules in the decoding processor can be executed. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor 41 reads the information in the memory 42 and completes the steps of the print data restoration method of the above embodiment in combination with its hardware.
[0079] An embodiment of the present invention further provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned print data restoration method. The specific implementation can be found in the above-mentioned method embodiment, which will not be repeated here.
[0080] The computer program product of the print data restoration method, print data restoration device and electronic device provided in the embodiments of the present invention includes a computer-readable storage medium storing program code. The instructions included in the above program code can be used to execute the above print data restoration method in the previous method embodiment. The specific implementation can be referred to the method embodiment, which will not be repeated here.
[0081] Unless otherwise specifically stated, the relative steps, numerical expressions and values of the components and steps set forth in these embodiments do not limit the scope of the present invention.
[0082] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that can be executed by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the above methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0083] Finally, it should be noted that the above-mentioned embodiments are only specific implementation methods of the present invention, which are used to illustrate the technical solutions of the present invention rather than to limit it. The protection scope of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the above-mentioned embodiments, ordinary technicians in this field should understand that any technician familiar with this technical field can still modify the technical solutions recorded in the above-mentioned embodiments within the technical scope disclosed by the present invention, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the protection scope of the present invention.
Claims
1. A printing data restoration method, characterized in that: include: Get print data; Parsing the print data to obtain enhanced metafile information; Extracting font features from the enhanced metafile information; Performing a hash operation on the font feature to obtain a hash value; Matching the hash value with a preset standard hash value to obtain matched font information; The standard hash value is obtained in advance based on the analysis of preset standard font features; The restored printing data is determined according to the matched font information and the enhanced metafile information.
2. The printing data restoration method according to claim 1, characterized in that: The enhanced metafile information includes: vector graphics, text content and font information in the print data; The step of extracting font features from the enhanced metafile information comprises: extracting font features from the font information; The step of determining restored print data according to the matched font information and the enhanced metafile information comprises: The restored printing data is determined according to the matched font information, the vector graphics and the text content.
3. The printing data restoration method according to claim 2, characterized in that: The step of determining restored print data according to the matched font information, the vector graphics and the text content comprises: Determining restored text content according to the matched font information and text content; The restored printing data is determined according to the original text content and the vector graphics.
4. The printing data restoration method according to claim 2, characterized in that: The types of vector graphics include: straight lines, curves and polygons.
5. The printing data restoration method according to claim 1, characterized in that: The step of matching the hash value with a preset standard hash value to obtain matched font information comprises: Matching the hash value with a preset standard hash value to obtain a target character arrangement order, a target font style, and a target font size corresponding to the hash value; The target character arrangement order, target font style and target font size are determined as the matched font information.
6. The printing data restoration method according to claim 1, characterized in that: The number of the font features is multiple; after the step of extracting the font features from the enhanced metafile information, the method further includes: Arranging the font features in series according to a preset order to obtain arranged font features; The step of performing a hash operation on the font feature to obtain a hash value comprises: A hash operation is performed on the arranged font features to obtain a hash value.
7. The printing data restoration method according to claim 1, characterized in that: After the step of determining restored print data according to the matched font information and the enhanced metafile information, the method further comprises: Obtain updated font feature information supplemented by the user; Determining an update standard hash value according to the updated font feature information; Matching the hash value with the update standard hash value to obtain updated font information; According to the updated font information and the enhanced metafile information, the updated print data is determined.
8. A printing data restoration device, characterized in that: include: A data acquisition module, used for acquiring printing data; A data parsing module, used for parsing the printing data to obtain enhanced metafile information; A feature extraction module, used for extracting font features from the enhanced metafile information; A hash calculation module, used for performing a hash operation on the font features to obtain a hash value; A font matching module, used to match the hash value with a preset standard hash value to obtain matched font information; The standard hash value is obtained in advance based on the analysis of preset standard font features; The data restoration module is used to determine the restored printing data according to the matched font information and the enhanced metafile information.
9. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the print data restoration method according to any one of claims 1 to 7.
10. A computer storage medium, characterized in that: The computer storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the print data restoration method according to any one of claims 1 to 7.