OFD text editing method, device, computer equipment and computer-readable storage medium based on artificial intelligence

Through artificial intelligence-based methods, paragraph recognition and text encapsulation of OFD files, the offset of inserted characters is calculated and layout adjustment is made, which solves the problem of unsightly layout in OFD text paragraph editing, and achieves a high accuracy and beautiful editing effect.

CN119378505BActive Publication Date: 2025-04-04ADVANCED SYST DEV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411960645.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-30
Publication Date
2025-04-04
Estimated Expiration
2044-12-30

AI Technical Summary

Technical Problem

The existing OFD text paragraph editing technology is difficult to effectively insert text statements and perform paragraph editing, resulting in unsightly layout and prone to unsatisfactory versions after editing.

Method used

Using an artificial intelligence-based method, paragraph spacing and line spacing are recognized for the OFD file to be modified, the text to be inserted is encapsulated into word blocks, and the offset of the inserted word blocks is calculated to determine whether text overwrites or exceeds the boundary. If it occurs, resegment and paragraph layout adjustment are performed.

Benefits of technology

It realizes beautiful editing of OFD files, solves the problem of unsatisfactory layout after editing, improves the correctness of paragraph modification of different fonts and fonts, and avoids text overwriting and exceeding page boundaries.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119378505B_ABST
    Figure CN119378505B_ABST
Patent Text Reader

Abstract

The present invention discloses an OFD text editing method, device, computer equipment and computer-readable storage medium based on artificial intelligence. The present invention uses artificial intelligence technology to identify the paragraph spacing and line spacing of the OFD file to be modified; encapsulates the text to be inserted into a word block, and calculates the offset of the inserted word block; according to the offset of the inserted word block, it is judged whether the text will be covered or exceed the boundary after the word block is inserted. If it will occur, it will be re-segmented and arranged, and the paragraph layout adjustment will be performed on the corresponding position in the page to be modified of the OFD file. If it will not occur, it will be directly inserted into the page to be modified of the OFD file. The present invention can realize the editing of the OFD file, and make the edited file layout beautiful, solve the problem of unsatisfactory alignment after editing, and at the same time reduce the number of segmented word blocks and reduce the volume of the OFD file.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of digital text editing, and specifically relates to an OFD text editing method, device, computer equipment and computer-readable storage medium based on artificial intelligence. Background Art

[0002] The current OFD paragraph editing situation makes it difficult to insert text sentences into paragraphs and segment the text blocks on the OFD page generated after paragraph editing. Different fonts and glyphs may lead to unsightly layout. Due to the different implementation methods of various OFD readers, it is easy to cause unsatisfactory layout after editing. Summary of the invention

[0003] The present invention aims to solve the technical problems existing in the prior art, and provides an OFD text editing method, device, computer equipment and computer-readable storage medium based on artificial intelligence, which uses artificial intelligence technology to identify the paragraph spacing and line spacing of the OFD file to be modified; encapsulate the text to be inserted into a word block, and calculate the offset of the inserted word block; according to the offset of the inserted word block, determine whether the text will be covered or exceed the boundary after the insertion of the word block, if it will happen, re-segment and arrange, and adjust the paragraph layout of the corresponding position in the page to be modified in the OFD file, if it will not happen, directly insert it into the page to be modified in the OFD file. The present invention can realize the editing of OFD files, make the edited file layout beautiful, and solve the problem of unsatisfactory alignment after editing.

[0004] The present invention provides an OFD text editing method based on artificial intelligence, comprising the following steps:

[0005] Use artificial intelligence technology to identify paragraph spacing and line spacing in the OFD file to be modified;

[0006] Encapsulate the text to be inserted into a block and calculate the offset of the inserted block;

[0007] Based on the offset of the inserted character block, determine whether the text will overlap or exceed the boundary after the inserted character block. If so, re-divide and rearrange it, and adjust the paragraph layout of the corresponding position in the page to be modified in the OFD file. If not, directly insert it into the page to be modified in the OFD file.

[0008] Preferably, paragraph recognition is performed using an OCR image recognition model and algorithm.

[0009] Preferably, the OCR image recognition model is a CRNN model or a Vision LAN model.

[0010] Preferably, according to the offset of the inserted word block, it is determined whether the word block will be overlapped or exceed the boundary after the word block is inserted. If so, the word block is re-divided and arranged, and the paragraph layout is adjusted at the corresponding position in the page to be modified in the OFD file, which specifically includes the following steps:

[0011] According to the offset of the inserted word block, the inserted line and the inserted paragraph position in the page, it is judged whether the word block will be covered or exceed the boundary after the word block is inserted. If so, the covered part of the word or the word exceeding the boundary is segmented according to the font and font size of the covered part of the word, and the paragraphs are reorganized to generate a modified OFD page;

[0012] Determine whether the modified OFD page will expand to adjacent pages. If not, save the changes to the OFD file. If so, reorganize the paragraphs and recursively process adjacent pages until all pages have no text coverage, exceed the page boundaries, or expand to adjacent pages. Save the changes to the OFD file.

[0013] Preferably, judging whether text overlap or exceeds the boundary after inserting the word block is determined according to the offset of the inserted word block, the position of the inserted line and the inserted paragraph in the page, specifically comprises the following steps:

[0014] Determine the insertion point coordinates by responding to a user click event;

[0015] Calculate the relative displacement of the block behind the insertion point after the insertion of the block relative to the block before the insertion according to the offset of the inserted block and the coordinates of the insertion point;

[0016] Calculate the position of the first word after the insertion point after the insertion word block according to the insertion point coordinates and relative displacement;

[0017] If after calculating the inserted word block, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraphs are shifted backwards by line. When the inserted paragraph exceeds the boundary of this page, the exceeding lines and the subsequent adjacent paragraphs are shifted backwards by line.

[0018] Preferably, the relative displacement includes a horizontal axis displacement and a vertical axis displacement.

[0019] Preferably, the offset TB of the inserted word block is calculated offset , when TB offset The length from the insertion point to the end of the row to be inserted is L Distance When the excess part is added to the next line, the relative displacement of the subsequent text in the inserted character block is calculated, and so on, until the entire paragraph of text is adjusted.

[0020] Preferably, after inserting a character block, if the inserted character block requires adding a line, the average spacing is calculated based on the spacing between two adjacent lines of the inserted line. , the spacing between the newly added line and the two adjacent lines after the word block is inserted is determined according to the average spacing, where, is the line spacing between the adjacent previous lines, is the line spacing of the adjacent next line, is the average spacing.

[0021] Preferably, if after calculating the inserted word block, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraph is translated backwards by line, and the subsequent paragraphs are recursively adjusted according to the displacement of the previous paragraph. If paging is encountered, a new page can be added until there is no overlap in the text of all paragraphs.

[0022] Preferably, the criteria for determining whether text covers or exceeds the page editing limit are as follows:

[0023] When a text block is inserted, if the vertical coordinate of the block position moves backward and exceeds the vertical coordinate of the starting point of the next paragraph, it is considered that text overlay occurs;

[0024] When a text block is inserted, the last block of the paragraph, LastLineBox, is finally moved back and is considered to be beyond the page boundary if it is not completely contained by the page box ContentBox.

[0025] Preferably, the characters to be inserted are packaged into the character blocks according to the font and font size of the characters to be inserted.

[0026] Preferably, the text to be inserted is analyzed, and text with different fonts and sizes are encapsulated in different character blocks. If the font and size of the text to be inserted are exactly the same as those of the inserted text, the text to be inserted is encapsulated as one complete character block.

[0027] Preferably, saving the modifications to the OFD file includes saving all displacement parameters and then rendering according to all displacement parameters.

[0028] The present invention also provides an OFD text editing device based on artificial intelligence, comprising:

[0029] The paragraph recognition module uses artificial intelligence technology to identify the paragraph spacing and line spacing of the OFD file to be modified;

[0030] The character block encapsulation and offset calculation module encapsulates the characters to be inserted into character blocks and calculates the offset of the inserted character blocks;

[0031] The page adjustment module determines whether the text will overlap or exceed the boundary after the inserted word block according to the offset of the inserted word block. If so, it will be re-divided and rearranged, and the paragraph layout will be adjusted at the corresponding position in the page to be modified in the OFD file. If not, it will be directly inserted into the page to be modified in the OFD file.

[0032] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and is characterized in that the processor implements the steps of the above-mentioned artificial intelligence-based OFD text editing method when executing the computer program.

[0033] The present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, the steps of the above-mentioned OFD text editing method based on artificial intelligence are implemented.

[0034] Compared with the prior art, the present invention has at least the following beneficial effects:

[0035] (1) The present invention recognizes paragraphs, paragraph spacing and line spacing, encapsulates the text to be inserted into blocks, and determines whether text overlap and page boundary exceedance will occur according to the offset of the blocks. If so, paragraph adjustment is performed. The present invention realizes the editing of OFD files, and the paragraph modification accuracy of mixed paragraphs with different fonts and glyphs is higher, and text overlap will not occur, so that the edited file layout is beautiful, and the problem of unsatisfactory alignment after editing is solved.

[0036] (2) In the case where the font size of the text to be inserted is the same as that of the text to be inserted, the present invention encapsulates the text to be inserted into one complete word block without repeated segmentation. Since the number of segmented word blocks is reduced, the number of word blocks written to the OFD page is reduced, and the OFD file size is reduced. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 This is a schematic diagram of paragraphs of an OFD file after being identified using artificial intelligence technology according to an embodiment of the present invention.

[0038] Figure 2 This is a schematic diagram of rows of an OFD file after being recognized using artificial intelligence technology according to an embodiment of the present invention.

[0039] Figure 3 A schematic diagram of packaging the text to be inserted into a text block and then inserting it into an OFD page according to an embodiment of the present invention;

[0040] Figure 4 A schematic diagram of segment spacing and character block length according to an embodiment of the present invention;

[0041] Figure 5 A schematic diagram of text overlay between paragraphs according to an embodiment of the present invention;

[0042] Figure 6 A schematic diagram of exceeding the page boundary according to an embodiment of the present invention;

[0043] Figure 7 A schematic diagram of an insertion point and an offset according to an embodiment of the present invention;

[0044] Figure 8 A schematic diagram of relative displacement (lateral relative displacement and longitudinal relative displacement) and average row spacing according to an embodiment of the present invention;

[0045] Fig. 9 The figure is a flow chart of an OFD text editing method based on artificial intelligence according to an embodiment of the present invention. DETAILED DESCRIPTION

[0046] 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. The described embodiments are only 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.

[0047] The present invention provides an OFD text editing method based on artificial intelligence, comprising the following steps:

[0048] Use artificial intelligence technology to identify paragraph spacing and line spacing in the OFD file to be modified;

[0049] Encapsulate the text to be inserted into a block and calculate the offset of the inserted block;

[0050] Based on the offset of the inserted character block, determine whether the text will overlap or exceed the boundary after the inserted character block. If so, re-divide and rearrange it, and adjust the paragraph layout of the corresponding position in the page to be modified in the OFD file. If not, directly insert it into the page to be modified in the OFD file.

[0051] According to a specific embodiment of the present invention, paragraph recognition is performed using an OCR image recognition model and algorithm.

[0052] According to a specific embodiment of the present invention, the OCR image recognition model is a CRNN model or a Vision LAN model.

[0053] According to a specific embodiment of the present invention, based on the offset of the inserted word block, it is determined whether the word block will be overlapped or exceed the boundary after the word block is inserted. If so, the word block is re-divided and arranged, and the paragraph layout is adjusted at the corresponding position in the page to be modified in the OFD file, which specifically includes the following steps:

[0054] According to the offset of the inserted word block, the inserted line and the inserted paragraph position in the page, it is judged whether the word block will be covered or exceed the boundary after the word block is inserted. If so, the covered part of the word or the word exceeding the boundary is segmented according to the font and font size of the covered part of the word, and the paragraphs are reorganized to generate a modified OFD page;

[0055] Determine whether the modified OFD page will expand to adjacent pages. If not, save the changes to the OFD file. If so, reorganize the paragraphs and recursively process adjacent pages until all pages have no text coverage, exceed the page boundaries, or expand to adjacent pages. Save the changes to the OFD file.

[0056] According to a specific embodiment of the present invention, judging whether a word block will be covered or exceed the boundary after the word block is inserted according to the offset of the inserted word block, the position of the inserted line and the inserted paragraph in the page specifically includes the following steps:

[0057] Determine the insertion point coordinates by responding to a user click event;

[0058] Calculate the relative displacement of the block behind the insertion point after the insertion of the block relative to the block before the insertion according to the offset of the inserted block and the coordinates of the insertion point;

[0059] Calculate the position of the first word after the insertion point after the insertion word block according to the insertion point coordinates and relative displacement;

[0060] If after calculating the inserted word block, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraphs are shifted backwards by line. When the inserted paragraph exceeds the boundary of this page, the exceeding lines and the subsequent adjacent paragraphs are shifted backwards by line.

[0061] According to a specific embodiment of the present invention, the relative displacement includes a horizontal axis displacement and a vertical axis displacement.

[0062] According to a specific embodiment of the present invention, the offset TB of the inserted word block is calculated. offset , when TB offset The length from the insertion point to the end of the row to be inserted is L Distance When the excess part is added to the next line, the relative displacement of the subsequent text in the inserted character block is calculated, and so on, until the entire paragraph of text is adjusted.

[0063] According to a specific embodiment of the present invention, after inserting a character block, if the insertion of the character block requires adding a line, the average spacing is calculated based on the spacing between two adjacent lines of the inserted line. , the spacing between the newly added line and the two adjacent lines after the word block is inserted is determined according to the average spacing, where, is the line spacing between the adjacent previous lines, is the line spacing of the adjacent next line, is the average spacing.

[0064] According to a specific implementation of the present invention, if after calculating the inserted word block, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraph is translated backwards by line, and the subsequent paragraphs are recursively adjusted according to the displacement of the previous paragraph. If paging is encountered, a new page can be added until there is no overlap in the text of all paragraphs.

[0065] According to a specific embodiment of the present invention, the criteria for judging text coverage and beyond page editing are as follows:

[0066] When a text block is inserted, if the vertical coordinate of the block position moves backward and exceeds the vertical coordinate of the starting point of the next paragraph, it is considered that text overlay occurs;

[0067] When a text block is inserted, the last block of the paragraph, LastLineBox, is finally moved back and is not completely contained by the page box ContentBox, it is considered to exceed the page boundary.

[0068] According to a specific embodiment of the present invention, the characters to be inserted are packaged into the character blocks according to the font and font size of the characters to be inserted.

[0069] According to a specific implementation of the present invention, the text to be inserted is analyzed, and text with different fonts and font sizes are encapsulated in different character blocks. When the font and font size of the text to be inserted are exactly the same as those of the inserted text, the text to be inserted is encapsulated as one complete character block.

[0070] According to a specific embodiment of the present invention, saving the modification to the OFD file includes saving all displacement parameters and then rendering according to all displacement parameters. The displacement parameters include the fixed point coordinates (x, y) of the first character of all character blocks and the displacement coordinates (DeltaX, DeltaY) of each character, as shown in the following table.

[0071]

[0072] The present invention also provides an OFD text editing device based on artificial intelligence, comprising:

[0073] The paragraph recognition module uses artificial intelligence technology to identify the paragraph spacing and line spacing of the OFD file to be modified;

[0074] The character block encapsulation and offset calculation module encapsulates the characters to be inserted into character blocks and calculates the offset of the inserted character blocks;

[0075] The page adjustment module determines whether the text will overlap or exceed the boundary after the inserted word block according to the offset of the inserted word block. If so, it will be re-divided and rearranged, and the paragraph layout will be adjusted at the corresponding position in the page to be modified in the OFD file. If not, it will be directly inserted into the page to be modified in the OFD file.

[0076] The present invention also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and is characterized in that the processor implements the steps of the above-mentioned artificial intelligence-based OFD text editing method when executing the computer program.

[0077] The present invention also provides a computer-readable storage medium having a computer program stored thereon, characterized in that when the computer program is executed by a processor, the steps of the above-mentioned OFD text editing method based on artificial intelligence are implemented.

[0078] Example 1

[0079] like Fig. 9 As shown, the present invention provides an OFD text editing method based on artificial intelligence, comprising the following steps:

[0080] Use artificial intelligence technology to identify paragraph spacing and line spacing in the OFD file to be modified;

[0081] Encapsulate the text to be inserted into a block and calculate the offset of the inserted block;

[0082] Based on the offset of the inserted character block, determine whether the text will overlap or exceed the boundary after the inserted character block. If so, re-divide and rearrange it, and adjust the paragraph layout of the corresponding position in the page to be modified in the OFD file. If not, directly insert it into the page to be modified in the OFD file.

[0083] Example 2

[0084] The present invention provides an OFD text editing method based on artificial intelligence, comprising the following steps:

[0085] Use the OCR image recognition model and algorithm to identify the paragraph spacing and line spacing of the OFD file to be modified, such as Figure 1 and Figure 2 As shown, the extracted paragraph spacing index is set to Pi, From the first paragraph, it is P 1, P 2, ...P n (like Figure 1 As shown), for each paragraph P i The middle line spacing is marked as L 1, L 2, ...L n ; The OCR image recognition model may be a CRNN model or a Vision LAN model (visual language modeling network), or other models and algorithms may be used, which are not the focus of the present invention and are not specifically limited by the present invention;

[0086] The text to be inserted is packaged into character blocks according to the font and size of the text to be inserted. The text to be inserted is analyzed, and different fonts and font sizes are packaged in different character blocks. If the font and font size of the text to be inserted are exactly the same as those of the text to be inserted, the text to be inserted is packaged into one complete character block (e.g. Figure 3 As shown), and calculate the offset of the inserted character block. In the case where the font size of the character to be inserted is the same as that of the inserted character, the present invention encapsulates the character to be inserted into one complete character block without repeated segmentation. Since the number of segmented character blocks is reduced, the number of character blocks written to the OFD page is reduced, and the OFD file size is reduced (compared with the OFD file size after editing without using the OFD file editing method of the present invention);

[0087] Based on the offset of the inserted character block, determine whether text will be overwritten after the character block is inserted (such as Figure 5 As shown, when y1<(y+dy), it is determined that the paragraph block has an overlap phenomenon) or exceeds the boundary phenomenon (such as Figure 6 As shown), if it appears, it is re-divided and arranged, and the paragraph layout is adjusted at the corresponding position in the page to be modified in the OFD file; if it does not appear, it is directly inserted into the page to be modified in the OFD file, which specifically includes the following steps:

[0088] According to the offset of the inserted word block, the inserted line and the inserted paragraph position in the page, it is judged whether the word block will be covered or exceed the boundary after the word block is inserted. If so, the covered part of the word or the word exceeding the boundary is segmented according to the font and font size of the covered part of the word, and the paragraphs are reorganized to generate a modified OFD page;

[0089] Determine whether the modified OFD page will expand to adjacent pages. If not, save the changes to the OFD file. If so, reorganize the paragraphs and recursively process adjacent pages until all pages have no text coverage, exceed the page boundary, or expand to adjacent pages. Save the changes to the OFD file, including saving all displacement parameters, and then render according to all displacement parameters.

[0090] Among them, Figure 7 As shown, according to the offset of the inserted word block, the position of the inserted line and the inserted paragraph in the page, it is determined whether the word block will be covered or exceed the boundary after the word block is inserted, which specifically includes the following steps:

[0091] Determine the insertion point coordinates by responding to a user click event;

[0092] Calculate the relative displacement of the block behind the insertion point after the insertion of the block relative to the block before the insertion according to the offset of the inserted block and the coordinates of the insertion point;

[0093] Calculate the position of the first word after the insertion point after the insertion word block according to the insertion point coordinates and relative displacement;

[0094] If after calculating the inserted word block, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraph is shifted backward by line. When the inserted paragraph exceeds the boundary of this page, the exceeding line and the subsequent adjacent paragraphs are shifted backward by line, wherein the relative displacement includes the horizontal coordinate displacement and the vertical coordinate displacement.

[0095] Among them, Figure 4 As shown, calculate the offset TB of the inserted word block offset , when TB offset The length from the insertion point to the end of the row to be inserted is L Distance When the excess part is added to the next line, the relative displacement of the subsequent text in the inserted character block is calculated, and so on, until the entire paragraph of text is adjusted.

[0096] After inserting a block, if the insertion of the block requires adding a line, the average spacing is calculated based on the spacing between the two adjacent lines of the inserted line. , the spacing between the newly added line and the two adjacent lines after the word block is inserted is determined according to the average spacing, where, is the line spacing between the adjacent previous lines, is the line spacing of the adjacent next line, is the average spacing.

[0097] Among them, if after the insertion block is calculated, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraph is translated backward by line, and the subsequent paragraphs are recursively adjusted according to the displacement of the previous paragraph. If paging is encountered, a new page can be added until there is no overlap in all paragraphs.

[0098] The criteria for determining whether text covers or exceeds the page editing limit are as follows:

[0099] When a text block is inserted, if the vertical coordinate of the block position moves backward and exceeds the vertical coordinate of the starting point of the next paragraph, it is considered that text overlay occurs;

[0100] When a text block is inserted, the last block of the paragraph, LastLineBox, is finally moved back and is not completely contained by the page box ContentBox, it is considered to exceed the page boundary.

[0101] Example 3

[0102] The present invention also provides an OFD text editing device based on artificial intelligence, comprising:

[0103] The paragraph recognition module uses artificial intelligence technology to identify the paragraph spacing and line spacing of the OFD file to be modified;

[0104] The character block encapsulation and offset calculation module encapsulates the characters to be inserted into character blocks and calculates the offset of the inserted character blocks;

[0105] The page adjustment module determines whether the text will overlap or exceed the boundary after the inserted word block according to the offset of the inserted word block. If so, it will be re-divided and rearranged, and the paragraph layout will be adjusted at the corresponding position in the page to be modified in the OFD file. If not, it will be directly inserted into the page to be modified in the OFD file.

[0106] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. An OFD text editing method based on artificial intelligence, characterized in that: The steps include: Use artificial intelligence technology to identify paragraph spacing and line spacing in the OFD file to be modified; Encapsulate the text to be inserted into a block and calculate the offset of the inserted block; According to the offset of the inserted word block, it is determined whether the word block will overlap or exceed the boundary after the word block is inserted. If so, the word block is re-segmented and arranged, and the paragraph layout is adjusted at the corresponding position in the page to be modified in the OFD file. If not, the word block is directly inserted into the page to be modified in the OFD file; The specific steps include: According to the offset of the inserted word block, the inserted line and the inserted paragraph position in the page, it is judged whether the word block will be covered or exceed the boundary after the word block is inserted. If so, the covered part of the word or the word exceeding the boundary is segmented according to the font and font size of the covered part of the word, and the paragraphs are reorganized to generate a modified OFD page; Determine whether the modified OFD page will expand to adjacent pages. If not, save the changes to the OFD file. If so, reorganize the paragraphs and recursively process adjacent pages until all pages have no text coverage, exceed the page boundary, or expand to adjacent pages. Save the changes to the OFD file. The method of judging whether the word block will be covered or exceed the boundary according to the offset of the inserted word block, the position of the inserted line and the inserted paragraph in the page specifically includes the following steps: Determine the insertion point coordinates by responding to a user click event; Calculate the relative displacement of the block behind the insertion point after the insertion of the block relative to the block before the insertion according to the offset of the inserted block and the coordinates of the insertion point; Calculate the position of the first word after the insertion point after the insertion word block according to the insertion point coordinates and relative displacement; If after calculating the inserted word block, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraphs are shifted backwards by line. When the inserted paragraph exceeds the boundary of this page, the exceeding lines and the subsequent adjacent paragraphs are shifted backwards by line.

2. The OFD text editing method based on artificial intelligence according to claim 1, characterized in that: Use OCR image recognition models and algorithms to perform paragraph recognition.

3. The OFD text editing method based on artificial intelligence according to claim 2, characterized in that: The OCR image recognition model is a CRNN model or a Vision LAN model.

4. The OFD text editing method based on artificial intelligence according to claim 1, characterized in that: The relative displacement includes a horizontal axis displacement and a vertical axis displacement.

5. The OFD text editing method based on artificial intelligence according to claim 1, characterized in that: Calculate the offset TB of the inserted word block offset , when TB offset The length from the insertion point to the end of the row to be inserted is L Distance When the excess part is added to the next line, the relative displacement of the subsequent text in the inserted character block is calculated, and so on, until the entire paragraph of text is adjusted.

6. The OFD text editing method based on artificial intelligence according to claim 1, characterized in that: After inserting a block, if the inserted block requires adding lines, the average spacing is calculated based on the spacing between the two adjacent lines of the inserted line. , the spacing between the newly added line and the two adjacent lines after the word block is inserted is determined according to the average spacing, where, is the line spacing between the adjacent previous lines, is the line spacing of the adjacent next line, is the average spacing.

7. The OFD text editing method based on artificial intelligence according to claim 1, characterized in that: If after calculating the inserted word block, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraph is shifted backwards by line, and the subsequent paragraphs are recursively adjusted according to the displacement of the previous paragraph. If a page break is encountered, a new page can be added until all paragraphs no longer overlap.

8. The OFD text editing method based on artificial intelligence according to claim 1, characterized in that: The criteria for determining text coverage and beyond page editing are as follows: When a text block is inserted, if the vertical coordinate of the block position moves backward and exceeds the vertical coordinate of the starting point of the next paragraph, it is considered that text is overwritten; When a text block is inserted, the last block of the paragraph, LastLineBox, is finally moved back and is not completely contained by the page box ContentBox, it is considered to exceed the page boundary.

9. The OFD text editing method based on artificial intelligence according to claim 1, characterized in that: The characters to be inserted are packaged into the character blocks according to the font and font size of the characters to be inserted.

10. The OFD text editing method based on artificial intelligence according to claim 9, characterized in that: The text to be inserted is analyzed, and text with different fonts and font sizes are encapsulated in different character blocks. If the font and font size of the text to be inserted are exactly the same as those of the inserted text, the text to be inserted is encapsulated as one complete character block.

11. The OFD text editing method based on artificial intelligence according to claim 1, characterized in that: Saving changes to the OFD file includes saving all displacement parameters and then rendering based on all displacement parameters.

12. An OFD text editing device based on artificial intelligence, characterized in that: include: The paragraph recognition module uses artificial intelligence technology to identify the paragraph spacing and line spacing of the OFD file to be modified; The character block encapsulation and offset calculation module encapsulates the characters to be inserted into character blocks and calculates the offset of the inserted character blocks; The page adjustment module determines whether the text will overlap or exceed the boundary after the inserted word block is inserted according to the offset of the inserted word block. If so, it will be re-divided and arranged, and the paragraph layout will be adjusted at the corresponding position in the page to be modified in the OFD file. If not, it will be directly inserted into the page to be modified in the OFD file. Specifically, it includes the following steps: According to the offset of the inserted word block, the inserted line and the inserted paragraph position in the page, it is judged whether the word block will be covered or exceed the boundary after the word block is inserted. If so, the covered part of the word or the word exceeding the boundary is segmented according to the font and font size of the covered part of the word, and the paragraphs are reorganized to generate a modified OFD page; Determine whether the modified OFD page will expand to adjacent pages. If not, save the changes to the OFD file. If so, reorganize the paragraphs and recursively process adjacent pages until all pages have no text coverage, exceed the page boundary, or expand to adjacent pages. Save the changes to the OFD file. The method of judging whether the word block will be covered or exceed the boundary according to the offset of the inserted word block, the position of the inserted line and the inserted paragraph in the page specifically includes the following steps: Determine the insertion point coordinates by responding to a user click event; Calculate the relative displacement of the block behind the insertion point after the insertion of the block relative to the block before the insertion according to the offset of the inserted block and the coordinates of the insertion point; Calculate the position of the first word after the insertion point after the insertion word block according to the insertion point coordinates and relative displacement; If after calculating the inserted word block, the inserted paragraph overlaps with the subsequent adjacent paragraphs, the overlapped paragraphs are shifted backwards by line. When the inserted paragraph exceeds the boundary of this page, the exceeding lines and the subsequent adjacent paragraphs are shifted backwards by line.

13. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the OFD text editing method based on artificial intelligence described in any one of claims 1-11 are implemented.

14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the OFD text editing method based on artificial intelligence described in any one of claims 1 to 11 are implemented.

Citation Information

Patent Citations

  • Document conversion method and device, computer equipment and computer readable storage medium

    CN113920510A

  • Watermark generation method and device, medium and electronic equipment

    CN116051346A