Method and device for generating digital-electronic format invoice
Through homomorphic character deviation correction and special character mapping mechanisms, character recognition errors in digital-electrical layout invoices are corrected, and special characters that are not supported dynamically replace the correct display of digital-electrical layout invoices is realized, improving the flexibility and scalability of the system.
Patent Information
- Application Number
- CN202510441275.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-09
- Publication Date
- 2025-08-01
AI Technical Summary
The existing digital-electric invoice generation software cannot display unsupported characters normally, especially in areas such as finance and manufacturing, resulting in characters being displayed as blocks or misidentified.
The homomorphic character deviation correction mechanism and the special character mapping mechanism are adopted to correct character recognition errors by looking for homomorphic character deviation correction tables and special character mapping tables, and dynamically replace unsupported special characters, using authorized font files available to users.
Ensure that each invoice field of digital-type invoice can be displayed correctly, solve the problem of abnormal character display and improve the flexibility and scalability of the system.
Smart Images

Figure CN120409452A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer technology, and particularly relates to a method and device for generating digital electronic invoices in the form of electronic invoices. Background Art
[0002] Digital electronic invoices in the form of electronic invoices, abbreviated as digital electronic invoices, are a type of fully digital electronic invoice that increases the convenience of delivering data in the XML format, reduces usage costs, and at the same time retains formats such as PDF and OFD for easy viewing and reading. Enterprises directly connected to the tax bureau generate the formats of digital electronic invoices in their own business systems and deliver them in accordance with the requirements in the "Format Specification for Digital Electronic Invoices of the Tax Bureau". The construction of the digital electronic invoice generation system in the form of electronic invoices has become an important part of the enterprise-side construction during the connection process between enterprises and the tax bureau, and the technologies for generating digital electronic invoice format files and typesetting technologies are the top priorities among them.
[0003] According to the requirements of the "Format Specification for Digital Electronic Invoices of the Tax Bureau", the default fonts used in the invoice layout include Song typeface, Kai typeface, and Courier New. During the typesetting process of the format file, fonts need to be loaded, font information needs to be read for typesetting, and then written into the file. The information that needs to be read includes character width, glyph outline, character mapping, Unicode encoding range, and specific encoding formats, etc. Font information is an essential element of typesetting, and how to extract and utilize font data well is the core of realizing the typesetting function.
[0004] Currently, the format generation software on the market mainly focuses on format files that meet regular business requirements. It can set the fonts used for displaying strings in the format. If there are characters in the string that are not supported by the set fonts, they cannot be displayed normally.
[0005] Application Content
[0006] The purpose of the embodiments of this application is to provide a method and device for generating digital electronic invoices in the form of electronic invoices to solve the defect that digital electronic invoices in the form of electronic invoices in the prior art cannot be displayed normally.
[0007] To solve the above technical problems, this application is implemented as follows:
[0008] In a first aspect, a method for generating digital electronic invoices in the form of electronic invoices is provided, including the following steps:
[0009] Parse the invoice data input by the user, extract each invoice field from the invoice data and format the invoice fields; create a field typesetting engine, and set the typesetting style information corresponding to each invoice field according to the invoice field typesetting requirements;
[0010] Replace the homoglyph characters with different codes in each invoice field according to the homoglyph correction table; load the corresponding available font files according to the invoice type style and filling fields of the digital electronic invoice, and update the font configuration in the field layout engine based on the available font files;
[0011] Perform character-by-character layout on the string data of each invoice field through the field layout engine and the special character mapping table, and generate a digital electronic invoice according to the layout result.
[0012] In a second aspect, a device for generating a digital electronic invoice is provided, including:
[0013] An analysis module, configured to analyze the invoice data input by the user, extract each invoice field from the invoice data and format the invoice field; create a field layout engine, and set the corresponding layout style information for each invoice field according to the invoice field layout requirements;
[0014] A replacement module, configured to replace the homoglyph characters with different codes in each invoice field according to the homoglyph correction table; load the corresponding available font files according to the invoice type style and filling fields of the digital electronic invoice, and update the font configuration in the field layout engine based on the available font files;
[0015] A layout module, configured to perform character-by-character layout on the string data of each invoice field through the field layout engine and the special character mapping table, and generate a digital electronic invoice according to the layout result.
[0016] By using the homoglyph correction mechanism and the special character mapping mechanism in the embodiments of the present application, it is possible to correct the misusage problems caused by some character recognition problems, and dynamically replace the special characters not supported by the font file, so as to ensure the correct display of each invoice field of the digital electronic invoice. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 is a flowchart of a method for generating a digital electronic invoice provided by an embodiment of the present application;
[0018] Figure 2 is a specific implementation diagram of generating a digital electronic invoice provided by an embodiment of the present application;
[0019] Figure 3 is a schematic structural diagram of a device for generating a digital electronic invoice provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0020] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts belong to the scope of protection of the present application.
[0021] The digital electronic invoice adopts the OFD / PDF format, and generating the PDF / OFD digital electronic format, especially the processing of characters during the typesetting process, is actually a very complex task. In addition to regular characters, it is also necessary to take into account some special characters and problematic characters, and at the same time consider the font licensing issue. In addition, the digital electronic invoice layout system has high requirements for system performance. Therefore, how to balance system performance and scalability while solving problems has become the key to the success or failure of system design. The present invention optimizes and designs the core character typesetting and processing process for such problems.
[0022] Currently, most of the layout generation software on the market is general-purpose. For platform-based products such as electronic invoices, which need to face all application scenarios in all vertical business fields of the whole society, the software on the market does not support well. For example, in the financial field, there are relatively strict requirements and scopes for the use of font files, and the system must be able to adapt to user fonts. Another example is the manufacturing field, where users often use some uncommon symbols to identify the specifications, models, etc. of products. The default font Unicode encoding range usually does not support them, and such characters are displayed as squares in the generated layout file. There are also some users' sales systems connected to the ERP system, with a high level of digitalization. The invoicing information is recognized through OCR technology, which improves the efficiency compared with manual entry, but occasionally there will be misrecognition problems, such as misrecognizing some characters as some homomorphic but different-meaning characters in the Kangxi radicals, and it is very difficult to detect such problems only by the human eye.
[0023] The embodiments of the present application improve and optimize the design of typesetting and processes in response to many problems exposed by general layout generation software during the process of generating digital electronic layout files, introduce various configuration and extension mechanisms, and comprehensively solve the above complex problems.
[0024] The overall concept of the embodiments of this application is to divide the typesetting of invoice field data into two main stages: pre-typesetting preprocessing and formal typesetting. Using a homograph correction table and an available font mapping table, homographs with different codes introduced by the OCR recognition system are filtered out during the preprocessing stage and corrected to the correct Unicode code values. At the same time, the default font in the invoice layout is adjusted to an authorized font available to the user. During the formal typesetting stage, a special character mapping table is used to resolve the issue of the default font being unable to display certain special characters. Dynamically configured character information such as width and glyph shape is used to ensure the correct overall display effect when different fonts are mixed.
[0025] The Unicode Basic Multilingual Plane includes the most commonly used coded characters, as well as the CJK Radical Supplement and Kangxi Radical character code segments. Some characters in the latter two code segments are similar in shape to commonly used Chinese characters, such as the character "青" (green) with code value U+2ED8 and the character "青" (green) with code value U+9752. The Homoglyph Correction Table lists these characters with identical glyphs but different Unicode code values and maps them to common characters. This table can be used to correct such misused characters before invoice typeset.
[0026] The default fonts used in digital invoice layout files include Songti, Kaiti, and Courier New. Users can use the authorized font mapping table to map the default fonts to internally available fonts based on their management requirements. Before invoice typeset, the system loads the user-specified font file through a table lookup, parses the font information, extracts character width, glyph data, and other font descriptive information, and implements dynamic font mapping.
[0027] The default font required by the digital electronic layout does not support special characters used in some special scenarios, such as the code value U+2205, which is an empty set character. This character is a mathematical operator code segment and cannot be displayed using the default font. For such cases, users can gradually collect and add special character code segments based on actual system scenarios. During invoice typesetting, the system will match special character code segments in the table when processing a character. If a code segment is matched, it will be marked and the character width will be used to continue typesetting. When the layout file is actually generated, the font information set in the tag lookup table will be used for writing.
[0028] The following describes in detail a method for generating a digital invoice provided by an embodiment of the present application through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0029] like Figure 1 FIG. 1 is a flow chart of a method for generating a digital invoice according to an embodiment of the present application, the method comprising the following steps:
[0030] Step 101: Parse the invoice data input by the user, extract each invoice field from the invoice data and format the invoice fields; create a field layout engine and set the corresponding layout style information for each invoice field according to the invoice field layout requirements.
[0031] Among them, the layout style information includes position, font, font size, line break rule and string data.
[0032] Step 102: Replace the homoglyphs with different codes in each invoice field according to the homoglyph correction table; load the corresponding available font files according to the ticket type style and filling fields of the digital invoice, and update the font configuration in the field layout engine based on the available font files.
[0033] Among them, the homoglyph correction table includes characters with the same glyph but different Unicode code values, and maps these characters to common characters.
[0034] Step 103: Perform character-by-character layout on the string data of each invoice field through the field layout engine and the special character mapping table, and generate a digital invoice according to the layout result.
[0035] Specifically, through the field layout engine, each character in the string data of each invoice field can be compared with the characters in the special character mapping table one by one. If it matches the characters in the special character mapping table, the corresponding font and character width in the special character mapping table are used to layout the character.
[0036] Among them, the special character mapping table includes the Unicode code value of the special character, the target font name and the character width under the target font.
[0037] Through the use of the homoglyph correction mechanism and the special character mapping mechanism in the embodiments of the present application, it is possible to correct the misusage problems caused by some character recognition problems and dynamically replace the special characters not supported by the font file, so as to ensure the correct display of each invoice field of the digital invoice.
[0038] In the embodiments of the present application, the specific implementation process of generating a digital invoice is as Figure 2 shown, including the following stages:
[0039] I. Digital invoice field parsing, creating a field layout engine
[0040] 1. Parse the invoice data fields, extract the data fields according to the invoice filling rules and format them;
[0041] 2. Create an invoice field layout engine and set the layout styles such as position, font, font size, line break rule and string data according to the invoice field layout requirements.
[0042] II. Pre - processing before typesetting, correcting misused characters, and mapping available fonts
[0043] 3. Input the string data of invoice fields, compare with the homoglyph correction table, and correct misused characters;
[0044] 4. According to the invoice type style and filling fields of digital invoices, collect the list of fonts to be used;
[0045] 5. Input the font list, search for the available font mapping table, and load the available font files item by item;
[0046] 6. Update the actually mapped font information to the typesetting engine.
[0047] III. The typesetting engine typesets the invoice field data and processes special characters simultaneously
[0048] 7. The typesetting engine starts typesetting;
[0049] 7.1. Take the next character. If it is the last character, jump to 8;
[0050] 7.2. Compare with the special character mapping table. If it is not a special character, jump to 7.4;
[0051] 7.3. Read the character mapping width and font information in the table and update them to the typesetting engine;
[0052] 7.4. Insert the current character at the end of the invoice field, set the character font, and move the current position or line break according to the character width;
[0053] 7.5. Complete the typesetting of the current character and jump to 7.1;
[0054] IV. Use the typesetting data to generate OFD / PDF digital invoice format files according to format requirements
[0055] 8. Generate digital invoice OFD / PDF format files according to the typesetting information;
[0056] 9. The program exits.
[0057] The key innovation points of the embodiments of this application include: using the default font mapping mechanism of digital invoice formats to achieve unauthorized font substitution; using the homoglyph correction mechanism to correct misuse problems caused by partial character recognition issues; using the special character mapping mechanism to dynamically substitute special characters not supported by font files; the special character mapping table and its structure design; and a hierarchical design that isolates the digital invoice format typesetting process from the writing of specific file formats PDF / OFD.
[0058] Based on the above innovative points, the embodiments of this application conduct a multi-layer design for character and font processing in the process of generating digital invoice formats, enhancing the flexibility and scalability of font usage in the digital invoice format system from three dimensions: font file usage, specific character usage, and error-prone character usage. Compared with similar software, the advantages of the present invention are obvious. For example, the default font can be remapped and configured according to the fonts available to the user, thus solving the font copyright problem. The layout engine algorithm is complex. Generally, similar software couples character layout, font usage, and file generation together, resulting in difficulties in solving other problems such as partial character font replacement and character dynamic correction, while such problems can be easily solved by the embodiments of this application.
[0059] As Figure 3 shown, the following is a schematic structural diagram of a device for generating a digital invoice format provided by an embodiment of this application, including:
[0060] A parsing module 310, configured to parse the invoice data input by the user, extract each invoice field from the invoice data and format the invoice field; create a field layout engine, and set the corresponding layout style information for each invoice field according to the invoice field layout requirements.
[0061] Among them, the layout style information includes position, font, font size, line break rule, and string data.
[0062] A replacement module 320, configured to replace the homoglyphic characters with different codes in each invoice field according to the homoglyphic character correction table; load the corresponding available font file according to the invoice type style and filled fields of the digital invoice format, and update the font configuration in the field layout engine based on the available font file.
[0063] Among them, the homoglyphic character correction table includes characters with the same glyph but different Unicode code values, and maps these characters to common characters.
[0064] A layout module 330, configured to perform character-by-character layout on the string data of each invoice field through the field layout engine and the special character mapping table, and generate a digital invoice format according to the layout result.
[0065] Specifically, the layout module 330 is specifically configured to compare each character in the string data of each invoice field with the characters in the special character mapping table through the field layout engine. If the character matches the character in the special character mapping table, the corresponding font and character width in the special character mapping table are used to layout the character.
[0066] Among them, the special character mapping table includes the Unicode code value of the special character, the target font name, and the character width under the target font.
[0067] Embodiments of the present application can correct misuse problems caused by some character recognition problems and dynamically replace special characters not supported by the font file by using a homomorphic character rectification mechanism and a special character mapping mechanism, thereby ensuring the correct display of each invoice field in the digital electronic invoice format.
[0068] Embodiments of the present application also provide a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, it implements each process of the method embodiment for generating a digital electronic invoice format described above and can achieve the same technical effects. To avoid repetition, it will not be elaborated here. Among them, the computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.
[0069] It should be noted that in this article, the term "including", "comprising" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements not only includes those elements but also includes other elements not explicitly listed, or also includes elements inherent to such a process, method, article or device. Without further limitations, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or device including the element.
[0070] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases, the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disc) and includes several instructions for causing a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in various embodiments of the present application.
[0071] The embodiments of the present application have been described above in conjunction with the accompanying drawings. However, the present application is not limited to the above specific embodiments. The above specific embodiments are merely illustrative and not restrictive. Under the inspiration of the present application, those of ordinary skill in the art can also make many forms without departing from the purpose of the present application and the scope protected by the claims, and all belong to the protection scope of the present application.
Claims
1. A method for generating an electronic invoice in digital form, characterized in that, It includes the following steps: Parse the invoice data input by the user, extract each invoice field from the invoice data, and format the invoice fields; Create a field layout engine, and set the corresponding layout style information for each invoice field according to the invoice field layout requirements; According to the homoglyph correction table, replace the homoglyphs with different codes in each invoice field; according to the ticket type style and filling fields of the digital electronic invoice, load the corresponding available font files, and update the font configuration in the field layout engine based on the available font files; Through the field layout engine and the special character mapping table, perform character-by-character layout on the string data of each invoice field, and generate a digital electronic invoice according to the layout result.
2. The method according to claim 1, wherein The performing character-by-character layout on the string data of each invoice field through the field layout engine and the special character mapping table specifically includes: Through the field layout engine, compare each character in the string data of each invoice field with the characters in the special character mapping table one by one. If the character matches the characters in the special character mapping table, use the corresponding font and character width in the special character mapping table to layout the character.
3. The method according to claim 1, wherein The homoglyph correction table includes characters with the same glyph but different Unicode code values, and maps the character to a common character.
4. The method according to claim 1, characterized in that The special character mapping table includes the Unicode code value of the special character, the target font name, and the character width under the target font.
5. The method according to claim 1, wherein The layout style information includes position, font, font size, line break rule, and string data.
6. A device for generating digital electronic invoices, characterized in that, It includes: A parsing module for parsing the invoice data input by the user, extracting each invoice field from the invoice data, and formatting the invoice fields; Create a field layout engine, and set the corresponding layout style information for each invoice field according to the invoice field layout requirements; A replacement module for replacing the homoglyphs with different codes in each invoice field according to the homoglyph correction table; according to the ticket type style and filling fields of the digital electronic invoice, load the corresponding available font files, and update the font configuration in the field layout engine based on the available font files; A layout module for performing character-by-character layout on the string data of each invoice field through the field layout engine and the special character mapping table, and generating a digital electronic invoice according to the layout result.
7. The device according to claim 6, wherein The layout module is specifically used to compare each character in the string data of each invoice field with the characters in the special character mapping table one by one through the field layout engine. If the character matches the characters in the special character mapping table, use the corresponding font and character width in the special character mapping table to layout the character.
8. The device according to claim 6, wherein The homoglyph correction table includes characters with the same glyph but different Unicode code values, and maps the character to a common character.
9. The device according to claim 6, characterized in that, The special character mapping table includes the Unicode code value of the special character, the target font name, and the character width under the target font.
10. The device according to claim 6, characterized in that, The layout style information includes position, font, font size, line break rule, and string data.