Document conversion method, device, computer equipment and storage medium
By parsing and synthesizing Type3 fonts in PDF documents into TrueType fonts, the problem of garbled characters after document conversion is solved, and the correct display and reading experience after document conversion are achieved.
Patent Information
- Application Number
- CN202011560286.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-25
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2040-12-25
AI Technical Summary
When converting documents in PDF file format to other formats, if the font used in the document is Type3 and the ToUnicode encoding table is incorrect, the converted text will be garbled. Existing technology cannot effectively solve this problem.
By parsing the document to be converted, it is judged whether the text font meets the preset requirements. If it does not meet the requirements, it will be synthesized into a TrueType font, and the synthesized TrueType font will be used to replace the garbled text that appears after the conversion to achieve the correct display of the document after conversion. .
It effectively avoids the problem of garbled text display after document conversion, ensuring the accuracy and readability of the conversion results.
Smart Images

Figure CN112632915B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a document processing method, and more specifically to a document conversion method, device, computer equipment and storage medium. Background Art
[0002] The PDF file format can encapsulate text, fonts, formats, colors, and graphics and images independent of equipment and resolution in a single file. This format file can also contain electronic information such as hypertext links, sounds, and dynamic images, supports special-length files, and has high integration and security and reliability.
[0003] When converting a document in PDF file format to a document in another format, if the font used in the text of the document is Type3 and its ToUnicode encoding table is incorrect, the text of the target format document will be displayed in garbled characters after conversion.
[0004] Therefore, it is necessary to design a new method to achieve the problem of no garbled characters after document conversion. Summary of the invention
[0005] The purpose of the present invention is to overcome the defects of the prior art and provide a document conversion method, device, computer equipment and storage medium.
[0006] To achieve the above object, the present invention adopts the following technical solution: a document conversion method, comprising:
[0007] Get the document to be converted;
[0008] Determining whether the text font in the document to be converted meets the preset requirements;
[0009] If the text fonts in the document to be converted meet the preset requirements, synthesizing the text fonts that meet the preset requirements to obtain an intermediate font;
[0010] The document to be converted is converted according to the intermediate font to obtain a conversion result.
[0011] A further technical solution is: the step of judging whether the text font in the document to be converted meets the preset requirements includes:
[0012] Parsing the document to be converted to obtain the type of the text font;
[0013] Determining whether the font type of the text includes a preset font type;
[0014] If the type of the text font includes a preset font type, the text font in the document to be converted meets the preset requirement;
[0015] If the text font type does not include a preset font type, the text font in the document to be converted does not meet the preset requirement.
[0016] A further technical solution is: after determining whether the text font in the document to be converted meets the preset requirements, it also includes:
[0017] If the text font in the conversion document does not meet the preset requirement, the document to be converted is converted to obtain a conversion result.
[0018] A further technical solution is: synthesizing the text fonts that meet the preset requirements to obtain an intermediate font, including:
[0019] The text fonts meeting the preset requirements are synthesized into TrueType fonts to obtain an intermediate font.
[0020] A further technical solution is: synthesizing the text fonts meeting the preset requirements into a TrueType font to obtain an intermediate font, including:
[0021] Obtaining character path information and encoding information of the text font that meets preset requirements;
[0022] Generate character outline information according to the character path information;
[0023] A TrueType font is synthesized according to the character outline information and the encoding information to obtain an intermediate font.
[0024] A further technical solution is: synthesizing a TrueType font according to the character outline information and the encoding information to obtain an intermediate font includes:
[0025] synthesizing a cmap table of a TrueType font according to the encoding information;
[0026] synthesizing a glyph table of a TrueType font according to the character outline information;
[0027] A table structure corresponding to a TrueType font is synthesized according to the cmap table and the glyph table to obtain an intermediate font.
[0028] A further technical solution is: performing document conversion on the document to be converted according to the intermediate font to obtain a conversion result, including:
[0029] Convert the document to be converted into a document in a specified format to obtain a preliminary result;
[0030] The intermediate font is used to replace the display text corresponding to the character path information in the preliminary result to obtain a conversion result.
[0031] The present invention also provides a document conversion device, comprising:
[0032] A document acquisition unit, used for acquiring a document to be converted;
[0033] A judging unit, used to judge whether the text font in the document to be converted meets the preset requirements;
[0034] A synthesis unit, configured to synthesize the text fonts meeting the preset requirements to obtain an intermediate font if the text fonts in the document to be converted meet the preset requirements;
[0035] The first conversion unit is used to perform document conversion on the document to be converted according to the intermediate font to obtain a conversion result.
[0036] The present invention further provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor implements the above method when executing the computer program.
[0037] The present invention also provides a storage medium, wherein the storage medium stores a computer program, and the computer program can implement the above method when executed by a processor.
[0038] Compared with the prior art, the beneficial effect of the present invention is as follows: the present invention parses the document to be converted and determines whether there are font types that will cause garbled characters to appear in the displayed text, synthesizes the text fonts corresponding to these font types into TrueType fonts, and uses the synthesized TrueType fonts to replace the displayed text that appears garbled characters after conversion to obtain a conversion result, thereby achieving the problem of no garbled characters appearing after the document conversion.
[0039] The present invention is further described below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0041] Figure 1 A schematic diagram of an application scenario of the document conversion method provided by an embodiment of the present invention;
[0042] Figure 2A flowchart of a document conversion method provided by an embodiment of the present invention;
[0043] Figure 3 A schematic diagram of a sub-process of a document conversion method provided by an embodiment of the present invention;
[0044] Figure 4 A schematic diagram of a sub-process of a document conversion method provided by an embodiment of the present invention;
[0045] Figure 5 A schematic diagram of a sub-process of a document conversion method provided by an embodiment of the present invention;
[0046] Figure 6 A schematic diagram of a sub-process of a document conversion method provided by an embodiment of the present invention;
[0047] Figure 7 A schematic block diagram of a document font synthesis device provided by an embodiment of the present invention;
[0048] Figure 8 A schematic block diagram of a determination unit of a document font synthesis device provided by an embodiment of the present invention;
[0049] Fig. 9 A schematic block diagram of a synthesis unit of a document font synthesis device provided by an embodiment of the present invention;
[0050] Fig.10 A schematic block diagram of an intermediate font acquisition subunit of a document font synthesis device provided in an embodiment of the present invention;
[0051] Fig.11 A schematic block diagram of a first conversion unit of a document font synthesis device provided by an embodiment of the present invention;
[0052] Fig.12 A schematic block diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0053] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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 creative work are within the scope of protection of the present invention.
[0054] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.
[0055] It should also be understood that the terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the specification of the present invention and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.
[0056] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0057] See also Figure 1 and Figure 2 , Figure 1 A schematic diagram of an application scenario of the document conversion method provided by an embodiment of the present invention. Figure 2 A schematic flow chart of a document conversion method provided by an embodiment of the present invention. The document conversion method is applied in a server. The server exchanges data with a terminal and obtains a document to be converted from the terminal. When the text font in the document to be converted does not have a set font type, such as a font type such as Type3 that produces garbled characters after conversion, it is necessary to synthesize these text fonts before converting the document to be converted, so that the converted document does not have garbled characters. When the text font in the document to be converted does not have a set font type, the document to be converted can be directly converted, and the converted document can be sent to the terminal for display.
[0058] The document conversion method provided by the embodiment of the present invention brings users an excellent reading and editing experience. It is also necessary to consider reducing the document size as much as possible without changing the content of the PDF document, so that the document is more efficient in dissemination and has lower requirements on the storage medium size during the storage process.
[0059] Figure 2 FIG. 1 is a flow chart of a document conversion method provided by an embodiment of the present invention. Figure 2 As shown, the method includes the following steps S110 to S150.
[0060] S110: Obtain the document to be converted.
[0061] In this embodiment, the document to be converted refers to a document from the terminal that needs to be converted, which can be a PDF format document or a word format document, etc. In addition, a conversion application is provided on the terminal. The operator can click on the conversion application to input the document to be converted and then execute the document conversion process.
[0062] S120: Determine whether the text font in the document to be converted meets preset requirements.
[0063] In one embodiment, see Figure 3 , the above-mentioned step S120 may include steps S121 to S124.
[0064] S121: Parse the document to be converted to obtain the type of the text font.
[0065] In this embodiment, the text fonts in the document to be converted need to be determined in order to filter out text fonts of a preset font type. Specifically, the preset font type refers to a font type such as Type 3 that produces garbled characters after conversion.
[0066] S122, determining whether the text font type includes a preset font type;
[0067] S123: If the text font type includes a preset font type, the text font in the document to be converted meets the preset requirement;
[0068] S124: If the text font type does not include a preset font type, the text font in the document to be converted does not meet the preset requirement.
[0069] When text fonts of a font type such as Type 3 that appear garbled after conversion appear in the document to be converted, synthesis processing is required to ensure that the final displayed text will not appear garbled. Therefore, it is necessary to first determine whether the text fonts in the document to be converted include fonts of a preset font type.
[0070] S130: If the text fonts in the document to be converted meet the preset requirements, synthesize the text fonts that meet the preset requirements to obtain an intermediate font.
[0071] In this embodiment, the intermediate font refers to a font corresponding to a display text that can avoid garbled characters, such as a TrueType font or other display text font that will not cause garbled characters.
[0072] Specifically, the text fonts meeting the preset requirements are synthesized into TrueType fonts to obtain an intermediate font.
[0073] In one embodiment, see Figure 4 , the above-mentioned step S130 may include steps S131 to S133.
[0074] S131. Obtain character path information and encoding information of the text font that meets preset requirements.
[0075] In this embodiment, the character path information refers to the location information of the text font that meets the preset requirements, and the encoding information refers to the glyph code of the text font.
[0076] S132: Generate character outline information according to the character path information.
[0077] In this embodiment, the character outline information refers to outline information formed by character path information, that is, outline position information.
[0078] Specifically, the character outline is formed according to the character path information in the order of appearance from the first to the last. The Type3 font outline information in PDF is located in the set dictionary, such as the document Resource dictionary->Font dictionary->CharProcs dictionary, and the character outline information is obtained by parsing these dictionaries.
[0079] S133, synthesizing a TrueType font according to the character outline information and the encoding information to obtain an intermediate font.
[0080] In this embodiment, the intermediate font is a font with a specific table structure, which is mainly composed of a cmap table and a glyph table.
[0081] In one embodiment, see Figure 5 , the above-mentioned step S133 may include steps S1331 to S1332.
[0082] S1331. Synthesize a cmap table of a TrueType font according to the encoding information.
[0083] In this embodiment, the cmap table is a mapping rule from the character encoding information used in the document to be converted to the encoding of each symbol in the font. The function of the cmap table is: given a string of known encoding, if the cmap table contains a subtable that supports the encoding, the corresponding glyph sequence in the font can be directly retrieved using the information in the cmap table without converting the encoding into UTF-16 or other encodings. Of course, if it is necessary to use OpenType features or process complex languages, this glyph sequence will be further replaced and adjusted in position with the help of the information in the GSUB and GPOS tables.
[0084] Specifically, the encoding information obtained from the PDF document can be written into the array corresponding to the cmap table. Since the encoding information obtained from the PDF document is a mapping of two data, it does not involve the data related to the array corresponding to the cmap table. At this time, the encoding information can be set to the data related to the array corresponding to the cmap table, that is, the encoding information character code = 1, the data glyph id = 1 related to the array corresponding to the cmap table; the encoding information character code = 2, the data glyph id = 2 related to the array corresponding to the cmap table, and so on, to synthesize the cmap table.
[0085] For example: the Type3 font encoding information in a PDF document is located in the document Resource dictionary->Font dictionary->Encoding dictionary->Differences array. The encoding information of the character character code->charactername is obtained by parsing. The Difference array is organized in the form of "code1 name1,1name1,2...", where "1" is the character code, the character name corresponding to character code 1 is "G1", and the character name corresponding to character code 2 is "G2", and so on, to synthesize the cmap table of the TrueType font.
[0086] S1332, synthesizing a glyph table of a TrueType font according to the character outline information;
[0087] In this embodiment, the glyph table provides precise control over glyph placement for complex text layout and rendering in every script and language system supported by a font.
[0088] The obtained character contour stream information is converted into a glyph table. The fields in the glyph table are all defined in advance. The field endPtsOfContours[n] in the glyph table corresponds to the character contour stream information. The point data in the character contour stream information is written into the field endPtsOfContours[n] in the glyph table, and the other data of the character contour stream information is written into the instructions[instructionLength] field of the glyph table to indicate the contour instructions "move to", "line to", and "line to". The other fields can be written according to actual needs, thereby synthesizing the glyph table of the TrueType font.
[0089] S1333. Synthesize a table structure corresponding to the TrueType font according to the cmap table and the glyph table to obtain an intermediate font.
[0090] When synthesizing TrueType fonts, it is necessary to generate the corresponding table structures in the TrueType font, including the cmap table, the glyph table and other table structures. Among them, the encoding information of the Type3 text font is parsed and used to synthesize the cmap table in the TrueType font. The character outline information obtained by parsing is used to synthesize the glyph table in the TrueType font, and then the other table structures in the TrueType font are initialized, and the TrueType font is synthesized with the help of the corresponding table structures in the TrueType font.
[0091] S140: Perform document conversion on the document to be converted according to the intermediate font to obtain a conversion result.
[0092] In this embodiment, the conversion result refers to converting the document to be converted into a document in a specified format, and the document does not have garbled characters.
[0093] In one embodiment, see Figure 6 , the above-mentioned S140 may include steps S141 to S142.
[0094] S141, converting the document to be converted into a document in a specified format to obtain a preliminary result.
[0095] In this embodiment, the preliminary result refers to a document formed after the document to be converted is converted into a specified format, and the document contains garbled display text.
[0096] In this embodiment, the PDF document to be converted is converted into a document in word format. Of course, in other embodiments, the document to be converted in other formats may be converted into a document in a specified format.
[0097] S142: Replace the display text corresponding to the character path information in the preliminary result with the intermediate font to obtain a conversion result.
[0098] In this embodiment, the preliminary result is a document with garbled display text, which cannot be sent directly to the terminal for display. The obtained intermediate font needs to replace the display text at the corresponding position in the preliminary result, that is, the garbled display text is replaced with the intermediate font.
[0099] Specifically, the synthesized TrueType font is embedded in the preliminary result. In this embodiment, the preliminary result is the target document after the PDF document is converted, such as a Word document. In the target document, the commonly used method of displaying text using Unicode is replaced by using the character code of the embedded TrueType font to display text, so as to avoid the problem of garbled characters.
[0100] The method is to extract the text fonts that meet the preset requirements, such as Type3, to synthesize the TrueType font, and then embed the TrueType font into the converted target document, so that the target document can display the Type3 font text normally.
[0101] S150: If the text font in the conversion document does not meet the preset requirement, perform document conversion on the document to be converted to obtain a conversion result.
[0102] When the converted document does not contain text fonts of the font type that will be garbled after conversion, such as Type 3, the converted document can be directly converted into a document of a specified format, and after conversion, it can be directly sent to the terminal for display.
[0103] For example: there is a PDF document containing one page. The page contains a text object used to display the text line "We'restill here keeping you covered". The page is parsed to obtain the content stream. From the parsed content stream, it can be seen that a text object is defined in the content stream, using the " / F" font. From the entry Subtype in the font dictionary, it can be seen that the font type is Type3. The value of the Subtype entry is " / Type3", and the font type referenced by the text object in the document is Type3. Then the Type3 font is synthesized into the corresponding TrueType font. When synthesizing the TrueType font, the corresponding table structure in the TrueType font needs to be generated, wherein the encoding information of the Type3 type is parsed and used to synthesize the cmap table in TrueType, and the character outline information obtained by parsing is used to synthesize the glyph table in TrueType, etc. Then other table structures in the TrueType font are initialized, and the synthesized TrueType font is embedded in the target document after the PDF document is converted, such as a Word document. In the target document, the commonly used method of displaying text using Unicode is replaced by a method of displaying text using the character code method of the embedded TrueType font, so that the text will not be garbled after the PDF document is converted into a Word document, which is conducive to dissemination and editing.
[0104] The above-mentioned document conversion method parses the document to be converted and determines whether there are font types that will cause garbled characters to appear in the displayed text, synthesizes the text fonts corresponding to these font types into TrueType fonts, and uses the synthesized TrueType fonts to replace the garbled characters in the displayed text after conversion to obtain the conversion result, thereby achieving the problem of no garbled characters appearing after the document conversion.
[0105] Figure 7FIG. 3 is a schematic block diagram of a document conversion device 300 provided in an embodiment of the present invention. Figure 7 As shown, corresponding to the above document conversion method, the present invention also provides a document conversion device 300. The document conversion device 300 includes a unit for executing the above document conversion method, and the device can be configured in a server. Figure 7 The document conversion device 300 includes a document acquisition unit 301, a judgment unit 302, a synthesis unit 303 and a first conversion unit 304.
[0106] The document acquisition unit 301 is used to acquire a document to be converted; the judgment unit 302 is used to judge whether the text font in the document to be converted meets the preset requirements; the synthesis unit 303 is used to synthesize the text font that meets the preset requirements to obtain an intermediate font if the text font in the document to be converted meets the preset requirements; the first conversion unit 304 is used to convert the document to be converted according to the intermediate font to obtain a conversion result.
[0107] In one embodiment, if Figure 7 As shown, the document conversion device 300 further includes a second conversion unit 305 .
[0108] The second conversion unit 305 is configured to perform document conversion on the document to be converted to obtain a conversion result if the text font in the conversion document does not meet a preset requirement.
[0109] In one embodiment, if Figure 8 As shown, the judgment unit 302 includes a parsing subunit 3021 and a type judgment subunit 3022 .
[0110] The parsing subunit 3021 is used to parse the document to be converted to obtain the type of the text font; the type judgment subunit 3022 is used to judge whether the type of the text font includes a preset font type; if the type of the text font includes the preset font type, the text font in the document to be converted meets the preset requirements; if the type of the text font does not include the preset font type, the text font in the document to be converted does not meet the preset requirements.
[0111] In one embodiment, the synthesis unit 303 is used to synthesize the text fonts that meet the preset requirements into a TrueType font to obtain an intermediate font.
[0112] In one embodiment, if Fig. 9 As shown, the synthesis unit 303 includes an information acquisition subunit 3031 , a contour acquisition subunit 3032 and an intermediate font acquisition subunit 3033 .
[0113] The information acquisition subunit 3031 is used to obtain the character path information and encoding information of the text font that meets the preset requirements; the outline acquisition subunit 3032 is used to generate character outline information based on the character path information; the intermediate font acquisition subunit 3033 is used to synthesize a TrueType font based on the character outline information and the encoding information to obtain an intermediate font.
[0114] In one embodiment, if Fig.10 As shown, the intermediate font acquisition subunit 3033 includes a first table synthesis module 30331 , a second table synthesis module 30332 and a table structure synthesis module 30333 .
[0115] The first table synthesis module 30331 is used to synthesize the cmap table of the TrueType font according to the encoding information; the second table synthesis module 30332 is used to synthesize the glyph table of the TrueType font according to the character outline information; the table structure synthesis module 30333 is used to synthesize the table structure corresponding to the TrueType font according to the cmap table and the glyph table to obtain an intermediate font.
[0116] In one embodiment, if Fig.11 As shown, the first conversion unit 304 includes a preliminary conversion subunit 3041 and a replacement subunit 3042 .
[0117] The preliminary conversion subunit 3041 is used to convert the document to be converted into a document of a specified format to obtain a preliminary result; the replacement subunit 3042 is used to replace the display text corresponding to the character path information in the preliminary result with the intermediate font to obtain a conversion result.
[0118] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned document font synthesis device and each unit can refer to the corresponding description in the aforementioned method embodiment, and for the convenience and brevity of description, it will not be repeated here.
[0119] The document font synthesis device can be implemented in the form of a computer program. Fig.12 Runs on the computer device shown.
[0120] See also Fig.12 , Fig.12 5 is a schematic block diagram of a computer device provided in an embodiment of the present application. The computer device 500 may be a server, wherein the server may be an independent server or a server cluster composed of multiple servers.
[0121] See also Fig.12The computer device 500 includes a processor 502 , a memory and a network interface 505 connected via a system bus 501 , wherein the memory may include a non-volatile storage medium 503 and an internal memory 504 .
[0122] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions, and when the program instructions are executed, the processor 502 can execute a document font synthesis method.
[0123] The processor 502 is used to provide computing and control capabilities to support the operation of the entire computer device 500 .
[0124] The internal memory 504 provides an environment for the operation of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a document font synthesis method.
[0125] The network interface 505 is used to communicate with other devices over the network. Fig.12 The structure shown in the figure is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device 500 to which the solution of the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0126] The processor 502 is used to run the computer program 5032 stored in the memory to implement the following steps:
[0127] Acquire a document to be converted; determine whether the text font in the document to be converted meets the preset requirements; if the text font in the document to be converted meets the preset requirements, synthesize the text font that meets the preset requirements to obtain an intermediate font; perform document conversion on the document to be converted according to the intermediate font to obtain a conversion result.
[0128] In one embodiment, when the processor 502 implements the step of determining whether the text font in the document to be converted meets the preset requirement, the processor 502 specifically implements the following steps:
[0129] The document to be converted is parsed to obtain the type of the text font; whether the type of the text font includes a preset font type is determined; if the type of the text font includes the preset font type, the text font in the document to be converted meets the preset requirements; if the type of the text font does not include the preset font type, the text font in the document to be converted does not meet the preset requirements.
[0130] In one embodiment, after implementing the step of determining whether the font of the text in the document to be converted meets the preset requirement, the processor 502 further implements the following steps:
[0131] If the text font in the conversion document does not meet the preset requirement, the document to be converted is converted to obtain a conversion result.
[0132] In one embodiment, when the processor 502 implements the step of synthesizing the text fonts that meet the preset requirements to obtain the intermediate font, the processor 502 specifically implements the following steps:
[0133] The text fonts meeting the preset requirements are synthesized into TrueType fonts to obtain an intermediate font.
[0134] In one embodiment, when the processor 502 implements the step of synthesizing the text fonts meeting the preset requirements into a TrueType font to obtain an intermediate font, the processor 502 specifically implements the following steps:
[0135] Acquire character path information and encoding information of the text font that meets preset requirements; generate character outline information according to the character path information; synthesize a TrueType font according to the character outline information and the encoding information to obtain an intermediate font.
[0136] In one embodiment, when the processor 502 implements the step of synthesizing a TrueType font according to the character outline information and the encoding information to obtain an intermediate font, the processor 502 specifically implements the following steps:
[0137] A cmap table of a TrueType font is synthesized according to the encoding information; a glyph table of a TrueType font is synthesized according to the character outline information; and a table structure corresponding to the TrueType font is synthesized according to the cmap table and the glyph table to obtain an intermediate font.
[0138] In one embodiment, when the processor 502 implements the step of converting the document to be converted according to the intermediate font to obtain a conversion result, the processor 502 specifically implements the following steps:
[0139] The document to be converted is converted into a document of a specified format to obtain a preliminary result; and the display text corresponding to the character path information in the preliminary result is replaced by the intermediate font to obtain a conversion result.
[0140] It should be understood that in the embodiment of the present application, the processor 502 may be a central processing unit (CPU), and the processor 502 may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0141] It can be understood by those skilled in the art that all or part of the processes in the method for implementing the above embodiment can be completed by instructing the relevant hardware through a computer program. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiment of the above method.
[0142] Therefore, the present invention also provides a storage medium. The storage medium may be a computer-readable storage medium. The storage medium stores a computer program, wherein when the computer program is executed by a processor, the processor executes the following steps:
[0143] Acquire a document to be converted; determine whether the text font in the document to be converted meets the preset requirements; if the text font in the document to be converted meets the preset requirements, synthesize the text font that meets the preset requirements to obtain an intermediate font; perform document conversion on the document to be converted according to the intermediate font to obtain a conversion result.
[0144] In one embodiment, when the processor executes the computer program to implement the step of determining whether the text font in the document to be converted meets the preset requirements, the processor specifically implements the following steps:
[0145] The document to be converted is parsed to obtain the type of the text font; whether the type of the text font includes a preset font type is determined; if the type of the text font includes the preset font type, the text font in the document to be converted meets the preset requirements; if the type of the text font does not include the preset font type, the text font in the document to be converted does not meet the preset requirements.
[0146] In one embodiment, after executing the computer program to implement the step of determining whether the text font in the document to be converted meets the preset requirement, the processor further implements the following steps:
[0147] If the text font in the conversion document does not meet the preset requirement, the document to be converted is converted to obtain a conversion result.
[0148] In one embodiment, when the processor executes the computer program to implement the step of synthesizing the text fonts that meet the preset requirements to obtain the intermediate font, the processor specifically implements the following steps:
[0149] The text fonts meeting the preset requirements are synthesized into TrueType fonts to obtain an intermediate font.
[0150] In one embodiment, when the processor executes the computer program to implement the step of synthesizing the text fonts that meet the preset requirements into a TrueType font to obtain an intermediate font, the processor specifically implements the following steps:
[0151] Acquire character path information and encoding information of the text font that meets preset requirements; generate character outline information according to the character path information; synthesize a TrueType font according to the character outline information and the encoding information to obtain an intermediate font.
[0152] In one embodiment, when the processor executes the computer program to implement the step of synthesizing a TrueType font according to the character outline information and the encoding information to obtain an intermediate font, the processor specifically implements the following steps:
[0153] A cmap table of a TrueType font is synthesized according to the encoding information; a glyph table of a TrueType font is synthesized according to the character outline information; and a table structure corresponding to the TrueType font is synthesized according to the cmap table and the glyph table to obtain an intermediate font.
[0154] In one embodiment, when the processor executes the computer program to implement the step of converting the document to be converted according to the intermediate font to obtain a conversion result, the processor specifically implements the following steps:
[0155] The document to be converted is converted into a document of a specified format to obtain a preliminary result; and the display text corresponding to the character path information in the preliminary result is replaced by the intermediate font to obtain a conversion result.
[0156] The storage medium may be a USB flash drive, a mobile hard disk, a read-only memory (ROM), a magnetic disk, or an optical disk, etc., which are computer-readable storage media that can store program codes.
[0157] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0158] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of each unit is only a logical function division, and there may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0159] The steps in the method of the embodiment of the present invention can be adjusted in order, combined and deleted according to actual needs. The units in the device of the embodiment of the present invention can be combined, divided and deleted according to actual needs. In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0160] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, terminal, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention.
[0161] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A document conversion method, characterized in that: include: Get the document to be converted; Determining whether the text font in the document to be converted meets the preset requirements; If the text fonts in the document to be converted meet the preset requirements, synthesizing the text fonts that meet the preset requirements to obtain an intermediate font; Performing document conversion on the document to be converted according to the intermediate font to obtain a conversion result; The synthesizing the text fonts meeting the preset requirements to obtain an intermediate font includes: Synthesizing the text fonts that meet the preset requirements into TrueType fonts to obtain an intermediate font; The step of synthesizing the text fonts meeting the preset requirements into a TrueType font to obtain an intermediate font includes: Obtaining character path information and encoding information of the text font that meets preset requirements; Generating character outline information according to the character path information; outlining the character outline formed from the beginning to the end in the order of appearance according to the character path information; synthesizing a TrueType font according to the character outline information and the encoding information to obtain an intermediate font; The synthesizing a TrueType font according to the character outline information and the encoding information to obtain an intermediate font includes: Synthesize a cmap table of a TrueType font according to the encoding information; set the encoding information to the data related to the array corresponding to the cmap table, that is, if the encoding information character code=1, the data related to the array corresponding to the cmap table glyph id=1; if the encoding information character code=2, the data related to the array corresponding to the cmap table glyph id=2, and so on, synthesize the cmap table; synthesizing a glyph table of a TrueType font according to the character outline information; A table structure corresponding to a TrueType font is synthesized according to the cmap table and the glyph table to obtain an intermediate font.
2. The document conversion method according to claim 1, characterized in that: The step of determining whether the text font in the document to be converted meets the preset requirements includes: Parsing the document to be converted to obtain the type of the text font; Determining whether the type of the text font includes a preset font type; If the type of the text font includes a preset font type, then the text font in the document to be converted meets the preset requirement; If the text font type does not include a preset font type, the text font in the document to be converted does not meet the preset requirement.
3. The document conversion method according to claim 1, characterized in that: After determining whether the text font in the document to be converted meets the preset requirements, the method further includes: If the text font in the conversion document does not meet the preset requirement, the document to be converted is converted to obtain a conversion result.
4. The document conversion method according to claim 1, characterized in that: The step of converting the document to be converted according to the intermediate font to obtain a conversion result includes: Convert the document to be converted into a document in a specified format to obtain a preliminary result; The intermediate font is used to replace the display text corresponding to the character path information in the preliminary result to obtain a conversion result.
5. A document conversion device, characterized in that: include: A document acquisition unit, used for acquiring a document to be converted; A judging unit, used to judge whether the text font in the document to be converted meets the preset requirements; A synthesis unit, configured to synthesize the text fonts meeting the preset requirements to obtain an intermediate font if the text fonts in the document to be converted meet the preset requirements; A first conversion unit, configured to perform document conversion on the document to be converted according to the intermediate font to obtain a conversion result; The synthesis unit is used to synthesize the text fonts that meet the preset requirements into a TrueType font to obtain an intermediate font; The synthesis unit includes an information acquisition subunit, a contour acquisition subunit and an intermediate font acquisition subunit; An information acquisition subunit is used to acquire character path information and encoding information of the text font that meets preset requirements; a contour acquisition subunit is used to generate character contour information according to the character path information; The character outline is formed from the first to the last according to the character path information in the order of appearance; the intermediate font acquisition subunit is used to synthesize the TrueType font according to the character outline information and the encoding information to obtain the intermediate font; The intermediate font acquisition subunit includes a first table synthesis module, a second table synthesis module and a table structure synthesis module; The first table synthesis module is used to synthesize the cmap table of the TrueType font according to the encoding information; the encoding information is set to the array-related data corresponding to the cmap table, that is, the encoding information character code=1, the array-related data glyph id=1 corresponding to the cmap table; the encoding information character code=2, the array-related data glyph id=2 corresponding to the cmap table, and so on, to synthesize the cmap table; the second table synthesis module is used to synthesize the glyph table of the TrueType font according to the character outline information; the table structure synthesis module is used to synthesize the table structure corresponding to the TrueType font according to the cmap table and the glyph table to obtain an intermediate font.
6. A computer device, characterized in that: The computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 4 when executing the computer program.
7. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 can be implemented.
