Cross-row and cross-column cell identification method, system and device in PDF-to-Word scene and medium

By identifying and classifying closed graph information, calculating the number of cross-row and cross-columns, the table recognition problem in cross-row and cross-columns in PDF tables is solved, and the accurate table conversion in PDF to Word is realized, which improves the conversion efficiency.

CN119272742APending Publication Date: 2025-01-07SICHUAN LAN-BRIDGE INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411450004.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

In the prior art, when converting PDF files to docx files, cross-row and cross-column situations in PDF tables cannot be accurately identified, resulting in incomplete table recognition.

Method used

By obtaining closed graph information, classifying and combining rows and column information into tables, calculating the number of cross-rows and columns, using infection algorithms and island algorithms to build table areas, and identifying the complete table.

Benefits of technology

It realizes accurate identification of cross-row and cross-column cells in the PDF to Word scenario, ensuring the complete conversion of table information, and does not rely on three-party tools, and has the advantage of speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119272742A_ABST
    Figure CN119272742A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of PDF (Portable Document Format) file analysis, and provides a method, a system and a device for identifying cross-row and cross-column cells in a PDF-to-Word scene and a medium, the method comprises the following steps: S1, obtaining all closed graphic information through a PDF table identification method, the closed graphic information comprising top, bottom, left and right information; s2, classifying closed graphs, and combining the closed graphs into row information of a table; s3, column information initialization is carried out in the second stage, wherein closed graphs are classified and combined into column information of a table; s4, calculating cross-row and cross-column numbers; and S5, completing table construction according to the calculated cross-row and cross-column numbers. By adopting the method, after the closed rectangle in the PDF is identified, the complete and accurate table can be accurately identified, so that the table information can be accurately and completely converted under the scene of converting the PDF into Word, and the method is realized by using a pure algorithm, does not need any three-party tool, and has a great speed advantage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of PDF file parsing, and specifically relates to a method, system, device and medium for identifying cross-row and cross-column cells in a PDF to Word conversion scenario. Background Art

[0002] When converting PDF files to docx files, there is often table information in the PDF file. Although there are solutions for PDF table information recognition in the prior art, the prior art cannot accurately recognize special cases where PDF tables involve cross-rows and cross-columns. Therefore, in the process of converting PDF files, how to accurately recognize complete and accurate tables when the tables are cross-rows and cross-columns has become a technical problem that needs to be solved urgently in this field. Summary of the invention

[0003] The purpose of the present invention is to provide a method for identifying cross-row and cross-column cells in a PDF to Word conversion scenario to solve the technical problems existing in the prior art.

[0004] In order to achieve the above object, the technical solution adopted by the present invention is as follows: A method for identifying cells across rows and columns in a PDF to Word conversion scenario includes the following steps: Step S1: Obtain all closed graphic information through the PDF table recognition method, where the closed graphic information has top, bottom, left, and right information; Step S2: Classify closed graphics and combine them into table row information: (2.1): Sort all closed graphics from top to bottom according to top information and from left to right according to left information to form a closed graphics set; (2.2): Traverse the closed graphics set according to the row information traversal method; Step S3: Initialize column information in two stages: classify closed graphics and combine them into column information of the table: (3.1): According to the row information of the table obtained in step S2, the row information contains at least one closed graphic, sort all closed graphics in order from left to right to form a closed graphic set; (3.2): Traverse the closed graphic set according to the column information traversal method; (3.3): Traverse the column information set, count the number of rows inside the current row when the row information top is used as the benchmark, record it as rowCount, and the set formed by the top of each row is record as tops; Step S4: Calculate the number of cross-rows and cross-columns; Step S5: Complete the construction of the table according to the calculated number of cross-rows and cross-columns.

[0005] In one embodiment, the row information traversal method is as follows: (2.2.1) If there is no row information for the current closed figure, create new row information with the top information of the current closed figure as the baseline, and add the current closed figure to the new row information; (2.2.2) If the current closed figure has row information, determine whether the top information of the current closed figure is equal to the row information top, and perform the following steps based on the determination result: (2.2.2.1) If the top information of the closed figure is equal to the top information of the row, determine whether the bottom information of the row needs to be updated, and determine whether the bootstrap of the current closed figure is greater than the bottom information of the row. If so, update it, mark the current row as having cell merges, and add the current closed figure to the current row. If not, do not update it, and add the current closed figure to the current row. (2.2.2.2) If the top information of the closed figure is not equal to the top of the row information, and the top information of the current closed figure is less than or equal to the bottom of the row information, determine whether the bootstrap of the current closed figure is greater than the bottom of the row information: if so, split the current closed figure according to the bottom of the row information into two closed figures, add the two closed figures to the queue, and sort them from top to bottom according to the top of the row information and from left to right according to the left information, then mark the current row as having a cell merge, and add the closed figure that is smaller than the bottom of the row information after the current split to the current row; if not, mark the current row as having a cell merge, and add the current closed figure to the current row; (2.2.2.3) If the top information of the closed figure is not equal to the top of the row information, and the top information of the current closed figure is greater than the bottom of the row information, save the row formed by the previous closed figure, construct a new row information, and add the current closed figure to the new row.

[0006] In one embodiment, the column information traversal method is as follows: (3.2.1) If the current column information set is empty, construct a new column information and add the current closed graph to the new column; (3.2.2) If the current column set is not empty, determine whether the current closed graph is included in a certain column information. If so, add the current closed graph to the current column. If not, construct a new column and add the current closed graph to the new column.

[0007] In one embodiment, the specific method of step S4 is as follows: (4.1): According to the cell merge marked in step S3, determine whether there is a row merge in the current row. If not, execute step (4.2). If so, execute step (4.3). (4.2): Generate new cells directly according to the row and column information sequence; (4.3): (4.3.1): Traverse the column information in the current row information, find which column has the most rows under the current row information, record it as rowCount; traverse all column information, and obtain the minimum height of each row according to tops, record it as minHeight; (4.3.2): Traverse the rowCount in step (4.3.1) to generate table rows. Each row is generated using the minHeight in step (4.3.1) as the height of the current row: Get the merge information mergeMaps of the current row, get the top row from the tops of the current column according to i, and then get the number of closed graphics in the current column according to top, traverse the closed graphics collection, if the current mergeMaps is not empty, according to the mergeMaps information, add cells to the current row, add dotted box style to the added cells, and calculate the number of cross-rows; (4.3.3): After all rows are traversed, a supplementary cell is created based on minHeight for row merging and added to the row merging information mergeMap; (4.3.4): Based on the left and right of the closed figure and the row information with the most columns, obtain the number of columns across the current closed figure and calculate the number of columns across.

[0008] In one embodiment, in step S1, the PDF form recognition method includes: Step S1.1: Construct line segments: obtain the coordinate information in the PDF, and generate all line segment information according to the path formed by the coordinate information; Step S1.2: Two-dimensional array conversion: Determine the size of the two-dimensional array according to the width and height of the PDF page: the height is used as rows and the width is used as columns. According to the line segment information obtained in step S1.1, determine the position of the line segment in the two-dimensional array, and set the value of the position of the area where the line segment is located to 1; Step S1.3: Constructing a table area using an infection algorithm: Step S1.3.1: Traverse the two-dimensional array, and when a value of a certain area position is equal to 1, starting from the current position, use the infection algorithm to infect all adjacent area positions with a value of 1; Step S1.3.2: Change the value of the area position from 1 to 2; Step S1.3.3: Obtain the overall infection range, and construct a table area based on the infection range; Step S1.4: constructing cell information using the island algorithm: based on the table area constructed in step S3, traverse the table area, and when the value of a certain area position is equal to 0, start from the current position and use the island algorithm to obtain all islands in the table area, each island is each cell; Step S1.5: Get the left and right borders and the upper and lower borders information, and construct the border information according to the left and right borders and the upper and lower borders information: Step S1.6: Generate and verify closed area information: Use the cell information in step S1.4 and the border information in step S1.5 to form a closed figure; Step S1.7: Construct table information: After sorting the closed figures obtained in step S1.6 from top to bottom and from left to right, determine the continuity between the closed figures. If any edges are adjacent or overlapping, store them in the same set, and finally determine a complete table with a border.

[0009] To achieve the above object, the present invention also provides a system for realizing the method for identifying cells across rows and columns in the PDF to Word conversion scenario, comprising: PDF table recognition module: through the PDF table recognition method, all closed graphic information is obtained. The closed graphic information has top, bottom, left, and right information; Closed graph classification module: Closed graphs are classified and combined into table row information: (2.1): All closed graphs are sorted from top to bottom according to top information and from left to right according to left information to form a closed graph set; (2.2): The closed graph set is traversed according to the row information traversal method; Column information initialization module: Column information initialization is performed in two stages: closed graphics are classified and combined into column information of the table: (3.1): According to the row information of the table obtained in step S2, the row information contains at least one closed graphic, and all closed graphics are sorted in order from left to right to form a closed graphic set; (3.2): The closed graphic set is traversed according to the column information traversal method; (3.3): The column information set is traversed, and the number of rows inside the current row when the row information top is used as the benchmark is counted, which is recorded as rowCount, and the set formed by the top of each row is recorded as tops; Calculation module: calculate the number of cross-row and cross-column; Table construction module: Complete the construction of the table based on the calculated number of rows and columns.

[0010] To achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium on which a computer program is stored, and the computer program is executed by a processor to implement the method for identifying cross-row and cross-column cells in the PDF to Word scenario.

[0011] To achieve the above-mentioned purpose, the present invention also provides a device for identifying cross-row and cross-column cells in a PDF to Word scenario, comprising: a processor and a memory; the memory is used to store a computer program; the processor is connected to the memory, and is used to execute the computer program stored in the memory, so that the device for identifying cross-row and cross-column cells in the PDF to Word scenario executes the method for identifying cross-row and cross-column cells in the PDF to Word scenario.

[0012] Compared with the prior art, the present invention has the following beneficial effects: The present invention classifies and combines rows through the concept of baseline top, and then traverses the closed figure through the generated row information, classifies and combines the columns, and after obtaining the row and column information, the number of cross-rows is calculated through the relationship between minHeight and tops, and the number of cross-columns is calculated through the relationship between left, right and the column information of the row with the largest number of columns; after identifying the closed rectangle in the PDF, the complete and accurate table can be accurately identified, so that in the scenario of PDF to Word, the table information can be accurately and completely converted, and the present invention is implemented using a pure algorithm without the need for any third-party tools, and has a great speed advantage. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] Figure 1 This is a schematic flow chart of step S2 in Example 1 of the present invention.

[0014] Figure 2 This is a schematic flow chart of step S3 in Example 1 of the present invention.

[0015] Figure 3 The process diagram of step S4 in Example 1 of the present invention is shown in FIG. Figure 1 .

[0016] Figure 4 The process diagram of step S4 in Example 1 of the present invention is shown in FIG. Figure 2 .

[0017] Figure 5 The process diagram of step S4 in Example 1 of the present invention is shown in FIG. Figure 3 .

[0018] Figure 6 This is a principle block diagram of Example 3 of the present invention.

[0019] Figure 7This is a schematic diagram of the principle of Example 4 of the present invention. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to have a clearer understanding and knowledge of the present invention, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described below are only used to explain the present invention, and are convenient for understanding. The technical solutions provided by the present invention are not limited to the technical solutions provided by the following embodiments, and the technical solutions provided by the embodiments should not limit the protection scope of the present invention.

[0021] It should be noted that the illustrations provided in the following embodiments are only used to illustrate the basic concept of the present invention in a schematic manner. Therefore, the drawings only show components related to the present invention rather than being drawn according to the number, shape and size of components in actual implementation. In actual implementation, the form, quantity and proportion of each component may be changed arbitrarily, and the component layout may also be more complicated.

[0022] Example 1 like Figures 1 to 7 As shown, this embodiment provides a method for identifying cells across rows and columns in a PDF to Word conversion scenario, which includes the following steps: 1. Get all closed figures Through the PDF table recognition method, all closed graphics (cell) information is obtained. The closed graphics information has top, bottom, left, right and other information, where top refers to minY, bottom refers to maxY, left refers to minX, and right refers to maxX.

[0023] In this embodiment, the table recognition method includes the following steps: Step S1.1: Construct line segments: obtain the coordinate information in the PDF, and generate all line segment information according to the path formed by the coordinate information; Step S1.2: Two-dimensional array conversion: Determine the size of the two-dimensional array according to the width and height of the PDF page: the height is used as rows and the width is used as columns. According to the line segment information obtained in step S1.1, determine the position of the line segment in the two-dimensional array, and set the value of the position of the area where the line segment is located to 1; Step S1.3: Construct a table area using the infection algorithm: Step S1.3.1: Traverse the two-dimensional array, and when encountering a region position whose value is equal to 1, starting from the current position, use the infection algorithm to infect all adjacent region positions whose values ​​are 1; Step S1.3.2: Change the value of the region position from 1 to 2; Step S1.3.3: Obtain the overall infection range, and construct a table area based on the infection range. The method for constructing the table area is as follows: If a certain infection range has no gaps and is a complete rectangle, and the interior of the rectangle meets the characteristics of the table, then the infection range is judged to be a table area; Step S1.4: constructing cell information using the island algorithm: based on the table area constructed in step S3, traverse the table area, and when the value of a certain area position is equal to 0, start from the current position and use the island algorithm to obtain all islands in the table area, each island is each cell; Step S1.5: Obtain the left and right borders and the upper and lower borders information, and construct the border information based on the left and right borders and the upper and lower borders information: The specific method for obtaining the left and right borders is as follows: (51) Construct a two-dimensional preprocessing array d in the vertical direction, and the two-dimensional preprocessing array d records the heights of the continuous values ​​​​of 2 below each position; (52) Traverse the table area obtained in step S3 in the two-dimensional array. When encountering a position with a value of 2, record the current position as (i, j), and obtain the height height of the current position from the two-dimensional preprocessing array d; (53) Start traversing to the right from the same row of the current position (i, j), and obtain the continuous positions in the subsequent columns with a height equal to height from the two-dimensional preprocessing array d. The end position is recorded as k; (54) Generate a vertical border as the left or right border of the table area obtained in step S3, with a border height of height and a border width of k-j+1; (55) Complete the traversal and obtain all The vertical borders are obtained by traversing the table area obtained in step S3 in the two-dimensional array. When a position with a value of 2 is encountered, the position at this time is recorded as (i, j), and the width of the current position is obtained from the two-dimensional preprocessing array r. (3) Starting from the same row of the current position (i, j), traverse downwards and obtain the positions in the subsequent columns with a width equal to width from the two-dimensional preprocessing array r. The end position is recorded as k. (4) Generate a horizontal border as the upper or lower border of the table area obtained in step S3. The border height is width and the border height is k-j+1. (5) After the traversal is completed, obtain all horizontal borders and use them as the upper and lower borders. Step S1.6: Generate and verify closed area information: Use the cell information in step S1.4 and the border information in step S1.5 to form a closed figure; specifically, sort the left border, right border, top border, and bottom border, traverse the cell information obtained in step S4, and use the binary search method to locate the border information closest to the cell according to the vertex coordinate information of the cell. If the left border, right border, top border, and bottom border can be found for the cell at the same time, the current cell is determined to be a legal cell. If the left border, right border, top border, and bottom border cannot be found at the same time, the cell is discarded; Step S1.7: Construct table information: After sorting the closed figures obtained in step S1.6 from top to bottom and from left to right, determine the continuity between the closed figures. If any edges are adjacent or overlapping, store them in the same set, and finally determine a complete table with a border.

[0024] In this step, the two-dimensional preprocessing array d and the two-dimensional preprocessing array r are constructed using the prefix sum algorithm.

[0025] 2. Classify closed graphics and combine them into table row information (2.1): Sort all closed graphs from top to bottom and from left to right according to top information, forming a closed graph set; (2.2): Traverse the closed graph set according to the row information traversal method; The traversal method used in this step is as follows: (2.2.1) If there is no row information for the current closed figure, use the top information of the current closed figure as the baseline, create new row information, and add the current closed figure to the new row information; (2.2.2) If the current closed figure has row information, determine whether the top information of the current closed figure is equal to the row information top, and perform the following steps based on the determination result: (2.2.2.1) If the top information of the closed figure is equal to the top information of the row, determine whether the bottom information of the row needs to be updated, and determine whether the bootstrap of the current closed figure is greater than the bottom information of the row. If so, update it, mark the current row as having cell merges, and add the current closed figure to the current row. If not, do not update it, and add the current closed figure to the current row. (2.2.2.2) If the top information of the closed figure is not equal to the top of the row information, and the top information of the current closed figure is less than or equal to the bottom of the row information, determine whether the bootstrap of the current closed figure is greater than the bottom of the row information: if so, split the current closed figure according to the bottom of the row information into two closed figures, add the two closed figures to the queue, and sort them from top to bottom according to the top of the row information and from left to right according to the left information, then mark the current row as having a cell merge, and add the closed figure that is smaller than the bottom of the row information after the current split to the current row; if not, mark the current row as having a cell merge, and add the current closed figure to the current row; (2.2.2.3) If the top information of the closed figure is not equal to the top of the row information, and the top information of the current closed figure is greater than the bottom of the row information, save the row formed by the previous closed figure, construct a new row information, and add the current closed figure to the new row; preferably, in this step, the second stage can be called to initialize the column information.

[0026] Phase 3: Initialize column information: Classify closed graphs and combine them into table column information (3.1): According to the row information of the table obtained in step S2, the row information contains at least one closed figure, and all closed figures are sorted in order from left to right to form a closed figure set; (3.2): Traverse the closed graph set according to the column information traversal method; the traversal method in this step is as follows: (3.2.1) If the current column information set is empty, construct a new column information and add the current closed graph to the new column; (3.2.2) If the current column set is not empty, determine whether the current closed graph is included in a certain column information. If so, add the current closed graph to the current column (in the scenario where there are multiple cells in the same column). If not, construct a new column and add the current closed graph to the new column; (3.3): Traverse the column information set, count the number of rows in the current row when the current row takes the row information top as the benchmark, record it as rowCount, and the set formed by the top of each row is record as tops; in this step, the current row refers to the row that is currently undergoing column initialization; 4. Calculate the number of rows and columns (4.1): According to the cell merge marked in step S3, determine whether there is a row merge in the current row. If not, execute step (4.2): directly generate a new cell according to the row information and column information sequence; if so, execute step (4.3); (4.3): Execute according to the following circumstances: (4.3.1): Traverse the column information in the current row information, find which column has the most rows under the current row information, record it as rowCount; traverse all column information, and obtain the minimum height of each row according to tops, record it as minHeight; (4.3.2): Traverse the rowCount in step (4.3.1) to generate table rows. The minHeight in step (4.3.1) is used as the height of the current row for each row: Get the merge information mergeMaps of the current row, get the row top from the tops of the current column according to i, and then get the number of closed graphics in the current column according to top, traverse the closed graphics set, if the current mergeMaps is not empty, according to the mergeMaps information, supplement the cells for the current row, and supplement the dotted frame style for the supplemented cells, and calculate the number of cross-rows; In this step, the principle of calculating the number of cross-rows is as follows: Determine whether the current closed graphic has additional cross-rows under the current top, and whether there are additional cross-rows depends on the information recorded in mergeMaps, that is, if the current closed graphic covers multiple tops, and there are corresponding records for tops in mergeMaps, then the number of cross-rows can be determined by the number of covered records; (4.3.3): After all rows are traversed, a supplementary cell is created based on minHeight for row merging and added to the row merging information mergeMap. The principle is as follows: given tops and mergeMaps, we can know the tops range of the current column. The key of mergeMaps corresponds to top. By knowing how much top is covered by the current column, we can know how many cells actually need to be supplemented. (4.3.4): According to the left and right of the closed figure, and the row information with the most columns, the number of columns across the current closed figure is obtained and the number of columns across is calculated; the calculation process is as follows: The calculation principle is as follows: Taking the row information with the most columns as the benchmark, the number of columns that the left and right of the current row can cover is the number of columns across; 5. Complete the construction of the table based on the calculated number of rows and columns.

[0027] In this step, according to the number of cross-rows and cross-columns calculated in the above steps, the table information is constructed according to the ooxml structure of the docx document through the Java open source framework POI based on the known row, column, and cell information.

[0028] Example 2 like Figure 4 As shown, this embodiment provides a system for implementing the method for identifying cross-row and cross-column cells in the PDF to Word conversion scenario provided in Embodiment 1, including: PDF table recognition module: through the PDF table recognition method, all closed graphic information is obtained. The closed graphic information has top, bottom, left, and right information; Closed graph classification module: Closed graphs are classified and combined into table row information: (2.1): All closed graphs are sorted from top to bottom according to top information and from left to right according to left information to form a closed graph set; (2.2): The closed graph set is traversed according to the row information traversal method; Column information initialization module: Column information initialization is performed in two stages: closed graphics are classified and combined into column information of the table: (3.1): According to the row information of the table obtained in step S2, the row information contains at least one closed graphic, and all closed graphics are sorted in order from left to right to form a closed graphic set; (3.2): The closed graphic set is traversed according to the column information traversal method; (3.3): The column information set is traversed, and the number of rows inside the current row when the row information top is used as the benchmark is counted, which is recorded as rowCount, and the set formed by the top of each row is recorded as tops; Calculation module: calculate the number of cross-row and cross-column; Table construction module: Complete the construction of the table based on the calculated number of rows and columns.

[0029] It should be noted that it should be understood that the division of the various modules of the above system is only a division of logical functions, which corresponds to the method steps provided in Example 1 one by one; in actual implementation, all or part of them can be integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements; they can also be implemented in the form of hardware; some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. For example, a module can be a separately established processing element, or it can be integrated in a certain chip of the device for implementation. In addition, it can also be stored in the memory of the device in the form of program code, and a certain processing element of the above device calls and executes the function of a certain module, and the implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. The processing element described here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0030] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more specific integrated circuits, or one or more microprocessors, or one or more field programmable gate arrays, etc. For another example, when a module above is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system on a chip.

[0031] Example 3 This embodiment provides a computer-readable storage medium, on which a computer program is stored, and the computer program is executed by a processor to implement the method for identifying cells across rows and columns in the PDF to Word conversion scenario provided in Embodiment 1. A person of ordinary skill in the art can understand that all or part of the steps of implementing the method provided in Embodiment 1 can be completed by hardware related to the computer program, and the above-mentioned computer program can be stored in a computer-readable storage medium, and when the program is executed, the steps of the method provided in Embodiment 1 are executed; and the above-mentioned storage medium includes: ROM, RAM, magnetic disk or optical disk and other media that can store program codes.

[0032] Example 4 like Figure 5 As shown, this embodiment provides a device for identifying cross-row and cross-column cells in a PDF to Word scenario, including: a processor and a memory; the memory is used to store a computer program; the processor is connected to the memory, and is used to execute the computer program stored in the memory, so that the device for identifying cross-row and cross-column cells in a PDF to Word scenario executes the method for identifying cross-row and cross-column cells in a PDF to Word scenario provided in Example 1.

[0033] Specifically, the memory includes: ROM, RAM, disk, USB flash drive, memory card or CD and other media that can store program codes.

[0034] Preferably, the processor can be a general-purpose processor, including a central processing unit, a network processor, etc.; it can also be a digital signal processor, an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component.

[0035] The above embodiments are merely illustrative of the principles and effects of the present invention, and are not intended to limit the present invention. Anyone familiar with the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by a person of ordinary skill in the art without departing from the spirit and technical concept disclosed by the present invention shall still be covered by the claims of the present invention.

Claims

1. A method for identifying cells across rows and columns in a PDF to Word conversion scenario, characterized in that: The following steps are involved: Step S1: Obtain all closed graphic information through the PDF table recognition method, where the closed graphic information has top, bottom, left, and right information; Step S2: Classify closed graphics and combine them into table row information: (2.1): Sort all closed graphics from top to bottom according to top information and from left to right according to left information to form a closed graphics set; (2.2): Traverse the closed graphics set according to the row information traversal method; Step S3: Initialize column information in two stages: classify closed graphs and combine them into column information of a table: (3.1): According to the row information of the table obtained in step S2, the row information contains at least one closed graph, and all closed graphs are sorted in order from left to right to form a closed graph set; (3.2): Traverse the closed graph set according to the column information traversal method; (3.3): Traverse the column information set, count the number of rows in the current row when the current row is based on the row information top, record it as rowCount, and the set formed by the top of each row, record it as tops; Step S4: Calculate the number of cross-rows and cross-columns; Step S5: Complete the construction of the table according to the calculated number of cross-rows and cross-columns.

2. The method for identifying cells across rows and columns in a PDF to Word conversion scenario according to claim 1 is characterized in that: The row information traversal method is as follows: (2.2.1) If there is no row information for the current closed figure, create new row information with the top information of the current closed figure as the baseline, and add the current closed figure to the new row information; (2.2.2) If the current closed figure has row information, determine whether the top information of the current closed figure is equal to the row information top, and perform the following steps based on the determination result: (2.2.2.1) If the top information of the closed figure is equal to the top information of the row, determine whether the bottom information of the row needs to be updated, and determine whether the bootstrap of the current closed figure is greater than the bottom information of the row. If so, update it, mark the current row as having cell merges, and add the current closed figure to the current row. If not, do not update it, and add the current closed figure to the current row. (2.2.2.2) If the top information of the closed figure is not equal to the top of the row information, and the top information of the current closed figure is less than or equal to the bottom of the row information, determine whether the bootstrap of the current closed figure is greater than the bottom of the row information: if so, split the current closed figure according to the bottom of the row information into two closed figures, add the two closed figures to the queue, and sort them from top to bottom according to the top of the row information and from left to right according to the left information, then mark the current row as having a cell merge, and add the closed figure that is smaller than the bottom of the row information after the current split to the current row; if not, mark the current row as having a cell merge, and add the current closed figure to the current row; (2.2.2.3) If the top information of the closed figure is not equal to the top of the row information, and the top information of the current closed figure is greater than the bottom of the row information, save the row formed by the previous closed figure, construct a new row information, and add the current closed figure to the new row.

3. The method for identifying cells across rows and columns in a PDF to Word conversion scenario according to claim 2 is characterized in that: The column information traversal method is as follows: (3.2.1) If the current column information set is empty, construct a new column information and add the current closed graph to the new column; (3.2.2) If the current column set is not empty, determine whether the current closed figure is included in a certain column information. If so, add the current closed figure to the current column. If not, construct a new column and add the current closed figure to the new column.

4. The method for identifying cells across rows and columns in a PDF to Word conversion scenario according to claim 3 is characterized in that: The specific method of step S4 is as follows: (4.1): According to the cell merge marked in step S3, determine whether there is a row merge in the current row. If not, execute step (4.2). If so, execute step (4.3). (4.2): Generate new cells directly according to the row and column information sequence; (4.3): (4.3.1): Traverse the column information in the current row information, find which column has the most rows under the current row information, record it as rowCount; traverse all column information, and obtain the minimum height of each row according to tops, record it as minHeight; (4.3.2): Traverse the rowCount in step (4.3.1) to generate table rows. Each row is generated using the minHeight in step (4.3.1) as the height of the current row: Get the merge information mergeMaps of the current row, get the top row from the tops of the current column according to i, and then get the number of closed graphics in the current column according to top, traverse the closed graphics collection, if the current mergeMaps is not empty, according to the mergeMaps information, add cells to the current row, add dotted box style to the added cells, and calculate the number of cross-rows; (4.3.3): After all rows are traversed, a supplementary cell is created based on minHeight for row merging and added to the row merging information mergeMap; (4.3.4): Based on the left and right of the closed figure and the row information with the most columns, obtain the number of columns across the current closed figure and calculate the number of columns across.

5. The method for identifying cells across rows and columns in a PDF to Word conversion scenario according to claim 4 is characterized in that: In step S1, the PDF form recognition method includes: Step S1.1: Construct line segments: obtain the coordinate information in the PDF, and generate all line segment information according to the path formed by the coordinate information; Step S1.2: Two-dimensional array conversion: Determine the size of the two-dimensional array according to the width and height of the PDF page: the height is used as rows and the width is used as columns. According to the line segment information obtained in step S1.1, determine the position of the line segment in the two-dimensional array, and set the value of the position of the area where the line segment is located to 1; Step S1.3: Constructing a table area using an infection algorithm: Step S1.3.1: Traverse the two-dimensional array, and when a value of a certain area position is equal to 1, starting from the current position, use the infection algorithm to infect all adjacent area positions with a value of 1; Step S1.3.2: Change the value of the area position from 1 to 2; Step S1.3.3: Obtain the overall infection range, and construct a table area based on the infection range; Step S1.4: constructing cell information using the island algorithm: based on the table area constructed in step S3, traverse the table area, and when the value of a certain area position is equal to 0, start from the current position and use the island algorithm to obtain all islands in the table area, each island is each cell; Step S1.5: Get the left and right borders and the upper and lower borders information, and construct the border information according to the left and right borders and the upper and lower borders information: Step S1.6: Generate and verify closed area information: Use the cell information in step S1.4 and the border information in step S1.5 to form a closed figure; Step S1.7: Construct table information: After sorting the closed figures obtained in step S1.6 from top to bottom and from left to right, determine the continuity between the closed figures. If any edges are adjacent or overlapping, store them in the same set, and finally determine a complete table with a border.

6. A system for implementing the method for identifying cells across rows and columns in a PDF to Word conversion scenario as described in any one of claims 1 to 5, characterized in that: include: PDF table recognition module: through the PDF table recognition method, all closed graphic information is obtained. The closed graphic information has top, bottom, left, and right information; Closed graph classification module: Closed graphs are classified and combined into table row information: (2.1): All closed graphs are sorted from top to bottom according to top information and from left to right according to left information to form a closed graph set; (2.2): The closed graph set is traversed according to the row information traversal method; Column information initialization module: Column information initialization is performed in two stages: closed graphics are classified and combined into column information of the table: (3.1): According to the row information of the table obtained in step S2, the row information contains at least one closed graphic, and all closed graphics are sorted in order from left to right to form a closed graphic set; (3.2): The closed graphic set is traversed according to the column information traversal method; (3.3): Traverse the column information set, count the number of rows in the current row when the current row is based on the row information top, record it as rowCount, and the set formed by the top of each row, record it as tops; Calculation module: calculate the number of cross-row and cross-column; Table construction module: Complete the construction of the table based on the calculated number of rows and columns.

7. A computer-readable storage medium having a computer program stored thereon, characterized in that: The computer program is executed by a processor to implement the method for identifying cross-row and cross-column cells in a PDF to Word conversion scenario according to any one of claims 1 to 5.

8. A device for identifying cells across rows and columns in a PDF to Word conversion scenario, characterized in that: include: Processor and memory; The memory is used to store computer programs; The processor is connected to the memory and is used to execute the computer program stored in the memory, so that the cross-row and cross-column cell recognition device in the PDF to Word scenario executes the cross-row and cross-column cell recognition method in the PDF to Word scenario as described in any one of claims 1 to 5.