Method for reducing a pdf file

CN116402028BActive Publication Date: 2026-11-03WUHAN UNIV OF TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310105813.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-13
Publication Date
2026-11-03
Estimated Expiration
2043-02-13

AI Technical Summary

Technical Problem

Existing technologies suffer from poor recognition, information loss, inaccurate classification, and low efficiency when extracting table information from PDF files, especially when performing poorly on low-probability topic keyword matching.

Method used

The Faster R-CNN algorithm is used to detect and classify tables in PDF files. The table structure is restored by combining OpenCV morphological operations. Text information is extracted by PDFPlumber. Keywords are used for filtering and insertion into Excel to generate a simplified PDF file.

Benefits of technology

It achieves efficient and accurate extraction of table, image, and text information highly related to keywords, and generates simplified PDF files with high accuracy and efficiency.

✦ Generated by Eureka AI based on patent content.
Patent Text Reader

Abstract

The application relates to the technical field of PDF document processing, and discloses a PDF file simplification method, which comprises the following steps: selecting a PDF file, setting simplification parameters, directory keywords and text keywords, screening key page numbers and key paragraphs, starting from the first key page number, obtaining pictures and saving the pictures, obtaining a table, judging a continuation table, inserting an EXCEL, obtaining a paragraph, and judging the text keywords; the successful judgment is saved as a key paragraph; all paragraphs in the page are traversed; after the traversal is completed, the key paragraph is inserted into the EXCEL; a new page number is inserted in the EXCEL; the pictures saved in the picture list are traversed; the text keywords are judged; the successful judgment is inserted into the EXCEL; the operation is repeated until all the key page numbers are traversed; and the simplified PDF file is output. According to the PDF file simplification method, a simplified PDF is generated according to input keywords, table, picture and text information with high correlation with the keywords are obtained, the accuracy is high, and the efficiency is high.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of PDF document processing technology, and specifically to a method for simplifying PDF files. Background Technology

[0002] In the research and development of motherboard products, circuit design and PCB design are of paramount importance. In traditional electronic product design, experienced electronic engineers or layout engineers are needed to compile important information related to data sheets, design guides, and PCB layout guides, which serve as important references and design guidance for circuit design and verification. However, the above information is mostly in PDF files, and the compilation time often takes a long time.

[0003] When organizing documents, tables are the most intuitive and information-dense text format in a document. It is crucial to extract their structure and restore the text content accurately. The extracted table data can be used as important information to match the input keywords, thereby outputting a concise document summary.

[0004] Traditional methods for recognizing tables in PDFs include extracting tables through image processing, extracting tables based on the XML information read from the PDF, and extracting tables using convolutional neural networks. These three methods have the following problems:

[0005] The first method mainly relies on image recognition algorithms, but existing algorithms are not very effective at recognizing complex tables; the second method results in information loss when converting file formats; the third method yields very different extraction results depending on the training data, and the extracted tables appear as images that cannot be imported into Excel.

[0006] In addition, the traditional neural network text generation method can be summarized as follows: based on the pre-trained CNN to extract local features of word vectors, and then based on the local feature vectors, the RNN network with attention mechanism is used to extract features from the local feature vectors to obtain global semantic feature vectors, and then the global semantics are classified based on the Softmax network layer. The disadvantages of this method are: (1) The interpretability of neural networks is not good enough. For texts with significant feature effects in electronic manual data, neural networks are insufficient in terms of interpretable features and extensibility, which will lead to inaccurate classification and make it easy to make incorrect matching in the future; (2) The sample size of the text needs to reach a certain scale, and the sample size of low probability topic keywords also needs to reach a certain number, otherwise it will lead to inaccurate classification and thus the situation of incorrect matching between topic and keyword; Since this method requires a large number of samples, the processing efficiency of low probability topics is relatively low. Summary of the Invention

[0007] The purpose of this invention is to address the shortcomings of the aforementioned technologies by providing a method for simplifying PDF files. This method generates a simplified PDF based on input keywords, and obtains tables, images, and text information that are highly relevant to the keywords, achieving high accuracy and efficiency.

[0008] To achieve the above objectives, the method for simplifying PDF files according to the present invention includes the following steps:

[0009] A) Select the PDF file that needs to be simplified. The PDF file includes page numbers, images, tables, annotations, and paragraphs.

[0010] B) Set simplified parameters;

[0011] C) Set directory keywords and text keywords. Use directory keywords to filter the key page numbers from which information needs to be extracted, and use text keywords to filter the key paragraphs within the key page numbers.

[0012] D) Starting from the first key page number, retrieve the images on the key page, save the image list according to the page number_image numbering method, and return the range information of images on each page;

[0013] E) Obtain the table in the key page, determine if it is a continuation table, and insert the identified table into Excel;

[0014] F) Obtain the paragraphs in the key page numbers and perform text keyword judgment. If the judgment is successful, save them as key paragraphs. Traverse all paragraphs on the current page. After the traversal is completed, insert the key paragraphs into Excel.

[0015] G) Insert a new page number in Excel;

[0016] H) Iterate through the images stored in the image list, perform text keyword checks, and insert the successfully checked images into Excel;

[0017] I) Repeat steps D) to H) until all key pages have been traversed;

[0018] J) Output a simplified PDF file.

[0019] Preferably, in step B), the simplified parameters include the width used when saving the image, the position of the image name, the reading height of each page of the PDF, and the spacing of the annotations.

[0020] Preferably, in step E), if there are comments outside the table or comments spanning multiple pages, they are inserted into the last row of the table.

[0021] Preferably, before step D), the PDF file to be simplified is subjected to table extraction, including the following steps: input the PDF file, perform table detection on it, then restore the structure of the table, then obtain the text information in the table for text restoration, and output an editable table.

[0022] Preferably, when performing table detection, the Faster R-CNN algorithm is used to classify and predict tables and images in the PDF file. If the prediction probability exceeds a set first threshold, it is determined to be a table or an image. Specifically, the steps include:

[0023] 1) Convert the PDF file into a processed image, and obtain the feature map after convolution operation;

[0024] 2) The obtained feature map is processed by RPN (Region Proposals Networks) to obtain candidate boxes, and the candidate boxes are projected onto the feature map to obtain the corresponding feature matrix;

[0025] 3) Scale each feature matrix to a 7*7 feature map using ROI pooling, then flatten the feature map and pass it through a fully connected layer to obtain the prediction result.

[0026] Preferably, the working process of the Faster R-CNN algorithm includes the following steps:

[0027] 4) Create a dataset: Label the processed images converted from the PDF file using the labeling software labelimg. Add different labels to the tables and images on each processed image. After labeling, put the corresponding processed images and the generated XML files into the import path specified in the code to create a dataset for training.

[0028] 5) Training: Continue training based on the already trained model. The code uses the weights of the ResNet50 network to initialize the network structure, and then uses the dataset created in step 4) to train further to obtain weights that meet the requirements. Save the weights of the epoch with the best performance for prediction.

[0029] 6) Prediction: Use the weights obtained during training to predict the image to be processed, predict the images and tables in the image, and return the coordinates of four points in the image and table. In the production of simplified PDF files, this is used to provide the images and the required coordinates to extract the title and annotations.

[0030] Preferably, when restoring the structure of the table, the table position is detected by Faster R-CNN, then the table border is adjusted and expanded, the table in the processing image is extracted by a mask, and the image is grayscaled and binarized. Then, the morphological operations in OpenCV, namely dilation and erosion, are used. The operation area of ​​erosion and dilation is set as a horizontal and vertical bar, and the horizontal and vertical table lines are obtained. The horizontal and vertical table lines are superimposed to form a table image, and the intersection point of the horizontal table line and the vertical line is obtained by OpenCV's bitwise_and function. Finally, the data is written into the merged cell and cross-page table connections are performed.

[0031] Preferably, when writing to merged cells, duplicate intersections are filtered out, and the intersections are sorted by coordinates. The number of rows and columns of the table is calculated based on the intersection coordinates. First, the table columns are traversed sequentially, and the Excel column merging operation is performed. In a column of cells, every two horizontal intersections form a row. Starting from the second row, the presence of a straight line in each row is determined by checking the pixel value between the two intersections in each row.

[0032] If there is a straight line, the two cells above and below the line are not merged. Extract the coordinates of the cell above the line, perform text recognition on that cell, and write the text into Excel.

[0033] If there is no straight line, record the position of the row, continue to check for straight lines downwards, obtain the total number of cells that need to be merged, perform text recognition on the merged cell, merge the corresponding cells in the Excel file, and write the text into the Excel file.

[0034] Then, iterate through the table rows, merge rows in Excel, and check for merged rows and columns. In each row, starting from the second column, check if there are any straight lines in each column.

[0035] If a straight line is found, no operation is performed; if no straight line is found, continue to check for straight lines to the right, calculate the total number of cells that need to be merged in that row, and then check for straight lines downwards to determine whether multiple rows and columns need to be merged: if not, merge the corresponding horizontal cells in Excel and write the text; if so, calculate the number of rows and columns of the multiple rows and columns, merge the corresponding cells in Excel, and write the text.

[0036] Preferably, when connecting tables across pages: obtain the table name using PDFplumber based on the title position, split the table name, obtain the table name sequence number, count the number of pages occupied by the multi-page table, obtain the table name sequence number on the next page, if the table sequence numbers on two pages are the same, continue to obtain the table name sequence number on the next page until the table sequence numbers are different; obtain the intersection point of each page's table using OpenCV, write the first page's table into Excel and return the row number, remove the attribute rows of the second page's table, and write the first row of the second page's table into the last row of Excel based on the returned row number; when the number of columns on two pages' tables is different, determine whether the maximum number of columns in the two parts of the cross-page table is equal: if they are equal, connect them directly; if they are not equal, use the intersection point coordinates of the part with the larger number of columns as the reference, and offset the intersection point coordinates of the other parts of the table; use the maximum number of columns as the reference for determining the number of columns when merging cells in other tables.

[0037] Preferably, during text restoration, the PDFPlumber is rewritten, and the text containing subscripts and superscripts within the table, as well as the table's title and annotations, are obtained through the underlying printing instructions of the PDF, and then the text is restored.

[0038] Text extraction containing subscript and superscript information: Using the cell coordinates obtained in the structure restoration step as input, PDFPlumber is used to extract the character information in the range and rearrange it into a string. The string in each cell is divided into several segments, and each segment is stored as a dictionary containing text and subscript and superscript information. The dictionary is stored in the form of a list.

[0039] Table title extraction: Iterate upwards several times from the top left corner of the table. If a table keyword is encountered, determine whether it is a title based on whether the keyword is at the beginning of the row and whether it is followed by a number. If it is, return the title information; otherwise, return an empty value. During the judgment process, the influence of spaces and line breaks should be removed.

[0040] Chapter title extraction guided by text extraction: Iterate upwards several times from the top left corner of the table. If a table keyword is encountered, return the title information if the keyword is a number or a number model, otherwise return an empty value. The effect of spaces and line breaks should be removed during the judgment process.

[0041] Chapter title extraction guided by reading the outline: For PDF files, the chapter information is stored in the underlying data of the PDF as an outline and includes page number information. This part can be read directly. When the chapter title and table are on the same page, take the first chapter title on that page.

[0042] Annotation extraction: Using the bottom coordinates of the table as a reference point, iterate downwards several times to extract the coordinates of annotation keywords and further extract their content.

[0043] Compared with the prior art, the present invention has the following advantages: it generates a simplified PDF based on the input keywords, and obtains tables, images and text information that are highly related to the keywords, with high accuracy and high efficiency. Detailed Implementation

[0044] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.

[0045] A method for simplifying PDF files includes the following steps:

[0046] A) Select the PDF file that needs to be simplified. The PDF file includes page numbers, images, tables, annotations, and paragraphs.

[0047] B) Set simplification parameters. In this embodiment, the simplification parameters include the width to be used when saving the identified images, the position of the image name (1 for the top of the image, others for the bottom), the reading height of each page of the PDF file (mainly to remove the influence of the header and footer, as PDF file formats are different, the default is greater than 40), the default spacing of the annotations (default is 5), and the number of pages for writing key paragraphs (related to the maximum number of columns in the table in the PDF file, which is 20).

[0048] C) Set directory keywords and text keywords. Use directory keywords to filter the key page numbers from which information needs to be extracted, and use text keywords to filter the key paragraphs within the key page numbers.

[0049] D) Starting from the first key page number, retrieve the images on the key page, save the image list according to the page number_image numbering method, and return the range information of images on each page;

[0050] E) Obtain the table in the key page, determine if it is a continuation table, and insert the identified table into Excel;

[0051] F) Obtain the paragraphs in the key page numbers and perform text keyword judgment. If the judgment is successful, save them as key paragraphs. Traverse all paragraphs on the current page. After the traversal is completed, insert the key paragraphs into Excel.

[0052] G) Insert a new page number in Excel;

[0053] H) Iterate through the images stored in the image list, perform text keyword checks, and insert the successfully checked images into Excel;

[0054] I) Repeat steps D) to H) until all key pages have been traversed;

[0055] J) Output a simplified PDF file.

[0056] In step B), the simplified parameters include the width used when saving the image, the position of the image name, the reading height of each page of the PDF, and the spacing of the annotations.

[0057] Additionally, in step E), if there are comments outside the table or comments spanning multiple pages, insert them into the last row of the table.

[0058] In this embodiment, before step D), the table of the PDF file to be simplified is extracted, including the following steps: input the PDF file, perform table detection on it, then restore the structure of the table, then obtain the text information in the table for text restoration, and output an editable table.

[0059] When performing table detection, the Faster R-CNN algorithm is used to classify and predict tables and images in PDF files. If the predicted probability exceeds a set first threshold, it is judged as a table or an image. The specific steps include the following:

[0060] 1) Convert the PDF file into a processed image, and obtain the feature map after convolution operation;

[0061] 2) The obtained feature map is processed by RPN (Region Proposals Networks) to obtain candidate boxes, and the candidate boxes are projected onto the feature map to obtain the corresponding feature matrix;

[0062] 3) Scale each feature matrix to a 7*7 feature map using ROI pooling, then flatten the feature map and pass it through a fully connected layer to obtain the prediction result.

[0063] The Faster R-CNN algorithm works by including the following steps:

[0064] 4) Create a dataset: Label the processed images converted from the PDF file using the labeling software labelimg. Add different labels to the tables and images on each processed image. After labeling, put the corresponding processed images and the generated XML files into the import path specified in the code to create a dataset for training.

[0065] 5) Training: Continue training based on the already trained model. The code uses the weights of the ResNet50 network to initialize the network structure, and then uses the dataset created in step 4) to train further to obtain weights that meet the requirements. Save the weights of the epoch with the best performance for prediction.

[0066] 6) Prediction: Use the weights obtained during training to predict the image to be processed, predict the images and tables in the image, and return the coordinates of four points in the image and table. In the production of simplified PDF files, this is used to provide the images and the required coordinates to extract the title and annotations.

[0067] Meanwhile, when restoring the table structure, the table position is detected by Faster R-CNN, and then the table borders are adjusted and expanded. The table in the processing image is extracted using a mask, and the image is grayscaled and binarized. Then, morphological operations in OpenCV, namely dilation and erosion, are used. The operation area of ​​erosion and dilation is set as a horizontal and vertical bar to obtain the horizontal and vertical table lines. The horizontal and vertical table lines are superimposed to form a table image, and the intersection point of the horizontal table lines and the vertical lines is obtained by OpenCV's bitwise_and function. Finally, the data is written into the merged cell and cross-page table connections are performed.

[0068] When writing to merged cells, duplicate intersections are filtered out, and the intersections are sorted by coordinates. The number of rows and columns in the table is calculated based on the intersection coordinates. First, the table columns are traversed sequentially, and the Excel column merge operation is performed. In a column of cells, every two horizontal intersections form a row. Starting from the second row, the existence of a straight line in each row is determined by checking the pixel value between two intersections in each row.

[0069] If there is a straight line, the two cells above and below the line are not merged. Extract the coordinates of the cell above the line, perform text recognition on that cell, and write the text into Excel.

[0070] If there is no straight line, record the position of the row, continue to check for straight lines downwards, obtain the total number of cells that need to be merged, perform text recognition on the merged cell, merge the corresponding cells in the Excel file, and write the text into the Excel file.

[0071] Then, iterate through the table rows, merge rows in Excel, and check for merged rows and columns. In each row, starting from the second column, check if there are any straight lines in each column.

[0072] If a straight line is found, no operation is performed; if no straight line is found, continue to check for straight lines to the right, calculate the total number of cells that need to be merged in that row, and then check for straight lines downwards to determine whether multiple rows and columns need to be merged: if not, merge the corresponding horizontal cells in Excel and write the text; if so, calculate the number of rows and columns of the multiple rows and columns, merge the corresponding cells in Excel, and write the text.

[0073] When joining tables across multiple pages: Obtain the table name using PDFplumber based on the header position. Split the table name to obtain its sequence number. Count the number of pages occupied by the multi-page table. Obtain the sequence number of the table name on the next page. If the sequence numbers of two pages are the same, continue obtaining the sequence numbers of the table name on the next page until the sequence numbers are different. Obtain the intersection point of each page's table using OpenCV. Write the first page's table into Excel and return the row count. Remove the attribute rows of the second page's table. Based on the returned row count, write the first row of the second page's table into the last row of Excel. When the number of columns in two pages' tables is different, determine if the maximum number of columns in the two parts of the cross-page table is equal. If equal, join directly. If not equal, use the intersection point coordinates of the part with the larger number of columns as the reference, and offset the intersection point coordinates of the other parts' tables. Use the maximum number of columns as the reference for determining the number of columns when merging cells in other tables.

[0074] When performing text restoration, the PDFPlumber is rewritten. By utilizing the underlying print commands of the PDF, text containing subscripts and superscripts within tables, as well as titles and annotations on the tables, are extracted and then restored.

[0075] Text extraction containing subscript and superscript information: Using the cell coordinates obtained in the structure restoration step as input, PDFPlumber is used to extract the character information in the range and rearrange it into a string. The string in each cell is divided into several segments, and each segment is stored as a dictionary containing text and subscript and superscript information. The dictionary is stored in the form of a list.

[0076] Table title extraction: Iterate upwards several times from the top left corner of the table. If a table keyword is encountered, determine whether it is a title based on whether the keyword is at the beginning of the row and whether it is followed by a number. If it is, return the title information; otherwise, return an empty value. During the judgment process, the influence of spaces and line breaks should be removed.

[0077] Chapter title extraction guided by text extraction: Iterate upwards several times from the top left corner of the table. If a table keyword is encountered, return the title information if the keyword is a number or a number model, otherwise return an empty value. The effect of spaces and line breaks should be removed during the judgment process.

[0078] Chapter title extraction guided by reading the outline: For PDF files, the chapter information is stored in the underlying data of the PDF as an outline and includes page number information. This part can be read directly. When the chapter title and table are on the same page, take the first chapter title on that page.

[0079] Annotation extraction: Using the bottom coordinates of the table as a reference point, iterate downwards several times to extract the coordinates of annotation keywords and further extract their content.

[0080] The present invention provides a method for simplifying PDF files, which generates a simplified version of the PDF based on input keywords and obtains tables, images, and text information that are highly relevant to the keywords. This method is highly accurate and efficient.

Claims

1. A method for simplifying PDF files, characterized in that: Includes the following steps: A) Select the PDF file that needs to be simplified. The PDF file includes page numbers, images, tables, annotations, and paragraphs. B) Set simplified parameters; C) Set table of contents keywords and text keywords. Use the table of contents keywords to filter the key page numbers from which you need to extract information, and use the text keywords to filter the key paragraphs within the key page numbers. D) Starting from the first key page number, retrieve the images on the key page, save the image list according to the page number_image numbering method, and return the range information of images on each page; E) Obtain the table in the key page, determine if it is a continuation table, and insert the identified table into Excel; F) Obtain the paragraphs in the key page numbers and perform text keyword judgment. Save the successfully judged paragraphs as key paragraphs. Traverse all paragraphs on the current page. After the traversal is completed, insert the key paragraphs into Excel. G) Insert a new page number in Excel; H) Iterate through the images stored in the image list, perform text keyword checks, and insert the successfully checked images into Excel; I) Repeat steps D) to H) until all key pages have been traversed; J) Output a simplified PDF file; Before step D), the tables in the PDF file that needs to be simplified are extracted, including the following steps: input the PDF file, perform table detection on it, then restore the structure of the table, then obtain the text information in the table for text restoration, and output an editable table. In the process of restoring the structure of the table, the table position is detected by Faster R-CNN, and then the table border is adjusted and enlarged. The table in the processing image is extracted by a mask, and the image is grayscaled and binarized. Then, the morphological operations in OpenCV, namely dilation and erosion, are used. The operation area of ​​erosion and dilation is set as a horizontal and vertical bar to obtain the horizontal and vertical table lines. The horizontal and vertical table lines are superimposed to form a table image. The intersection point of the horizontal table lines and the vertical lines is obtained by OpenCV's bitwise_and function. Finally, the data is written into the merged cell and cross-page table connections are performed. When writing to merged cells, duplicate intersections are filtered out, and the intersections are sorted by coordinates. The number of rows and columns of the table is calculated based on the intersection coordinates. First, the table columns are traversed sequentially, and the Excel column merging operation is performed. In a column of cells, every two horizontal intersections form a row. Starting from the second row, the existence of a straight line in each row is determined by checking the pixel value between the two intersections in each row. If there is a straight line, the two cells above and below the line are not merged. Extract the coordinates of the cell above the line, perform text recognition on that cell, and write the text into Excel. If there is no straight line, record the position of the row, continue to detect straight lines downwards, obtain the total number of cells that need to be merged, perform text recognition on the merged cells, merge the corresponding cells in the Excel file, and write the text into the Excel file. Next, iterate through the table rows, merge rows in Excel, and check for merged rows and columns. In each row, starting from the second column, check if there is a straight line in each column. If a straight line is found, no operation is performed; if no straight line is found, continue to check for straight lines to the right, calculate the total number of cells that need to be merged in that row, and then check for straight lines downwards to determine whether multiple rows and columns need to be merged: if not, merge the corresponding horizontal cells in Excel and write the text; if so, calculate the number of rows and columns of the multiple rows and columns that need to be merged, merge the corresponding cells in Excel, and write the text.

2. The method for simplifying PDF files as described in claim 1, characterized in that: In step B), the simplified parameters include the width used when saving the image, the position of the image name, the reading height of each page of the PDF, and the spacing of the annotations.

3. The method for simplifying PDF files as described in claim 1, characterized in that: In step E), if there are comments outside the table or comments that span multiple pages, insert them into the last row of the table.

4. The method for simplifying PDF files as described in claim 3, characterized in that: When performing table detection, the Faster R-CNN algorithm is used to classify and predict tables and images in PDF files. If the predicted probability exceeds a set first threshold, it is judged as a table or an image. The specific steps include the following: 1) Convert the PDF file into a processed image, and obtain the feature map after convolution operation; 2) After processing the obtained feature map with RPN, candidate boxes are obtained. The candidate boxes are then projected onto the feature map to obtain the corresponding feature matrix. 3) Scale each feature matrix to 7 using ROI pooling. A feature map of size 7 is generated, and then the feature map is flattened and passed through a fully connected layer to obtain the prediction result.

5. The method for simplifying PDF files as described in claim 4, characterized in that: The Faster R-CNN algorithm works through the following steps: 4) Create a dataset: Label the processed images converted from the PDF file using the labeling software labelimg. Add different labels to the tables and images on each processed image. After labeling, put the corresponding processed images and the generated XML file into the import path specified in the code to create a dataset to prepare for training. 5) Training: Continue training based on the already trained model. The code uses the weights of the ResNet50 network to initialize the network structure, and then uses the dataset created in step 4) to train further to obtain weights that meet the requirements. Save the weights of the epoch with the best performance for prediction. 6) Prediction: Use the weights obtained during training to predict the image to be processed, predict the images and tables in the image, and return the coordinates of four points in the image and table. In the production of simplified PDF files, this is used to provide the images and the required coordinates to extract the title and annotations.

6. The method for simplifying PDF files as described in claim 1, characterized in that: When connecting tables across multiple pages: Obtain the table name using PDFPlumber based on the header position, split the table name, obtain its sequence number, count the number of pages occupied by the multi-page table, and obtain the sequence number of the table name on the next page. If the sequence numbers of two pages are the same, continue obtaining the sequence numbers of the table name on the next page until the sequence numbers are different. Obtain the intersection point of each page's table using OpenCV, write the first page's table into Excel and return the row count, remove the attribute rows of the second page's table, and write the first row of the second page's table into the last row of Excel based on the returned row count. When the number of columns in two pages' tables is different, determine if the maximum number of columns in the two parts of the cross-page table is equal: if equal, connect directly; if not equal, use the intersection point coordinates of the part with the larger number of columns as the reference, and offset the intersection point coordinates of the other parts of the table. The maximum number of columns is used as the baseline for determining the number of columns when merging cells in other tables.

7. The method for simplifying PDF files as described in claim 6, characterized in that: When performing text restoration, the PDFPlumber is rewritten. By utilizing the underlying print commands of the PDF, text containing subscripts and superscripts within tables, as well as titles and annotations on the tables, are extracted and then restored. Text extraction containing subscript and superscript information: Using the cell coordinates obtained in the structure restoration step as input, PDFPlumber is used to extract the character information in the range and rearrange it into a string. The string in each cell is divided into several segments, and each segment is stored as a dictionary containing text and subscript and superscript information. The dictionary is stored in the form of a list. Table title extraction: Iterate upwards several times from the top left corner of the table. If a table keyword is encountered, determine whether it is a title based on whether the keyword is at the beginning of the row and whether it is followed by a number. If it is, return the title information; otherwise, return an empty value. During the judgment process, the influence of spaces and line breaks should be removed. Chapter title extraction guided by text extraction: Iterate upwards several times from the top left corner of the table. If a table keyword is encountered, determine whether the keyword is in the form of a number.number number. If it is, return the title information; otherwise, return an empty value. During the determination process, the influence of spaces and line breaks should be removed. Chapter title extraction guided by reading the outline: For PDF files, the chapter information is stored in the underlying data of the PDF as an outline and includes page number information. This chapter information can be read directly. When the chapter title and table are on the same page, take the first chapter title on that page. Annotation extraction: Using the bottom coordinates of the table as a reference point, iterate downwards several times to extract the coordinates of annotation keywords and further extract their content.

Citation Information

Patent Citations

  • System and method for extracting tables for PDF document

    CN110516208A