A page understanding-oriented PDF text content accurate extraction and structured reconstruction method and system

CN122965477APending Publication Date: 2026-10-23BEIJING TREND TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611252247.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-18
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

[0005]因此,本发明提供一种面向版面理解的PDF文字内容精准提取与结构化重建方法,用于解决PDF文本提取中版面类型不清、噪声过滤不完整、段落重建不稳定、位置不可回溯以及表图关系缺失的问题

Benefits of technology

[0016]本发明有益效果为:通过版面类型标注建立后续过滤和合并的基础;通过分层噪声规则、目录清理、层级标记保留和断开特征优先级,减少跨栏、跨层级和跨段误合并;通过位置标签、OCR坐标校准和跨页标签拆分,实现输出文本到源PDF区域的可回溯;通过表图分离及标题关联,提升结构化重建完整性。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122965477A_ABST
    Figure CN122965477A_ABST
Patent Text Reader

Abstract

The application discloses a PDF text content accurate extraction and structured reconstruction method and system for layout understanding, relates to the technical field of intelligent document processing, and comprises the following steps: acquiring a text box set carrying text content, page numbers and coordinate information in a PDF to be processed; marking the layout type of each text box according to the overlapping degree between the candidate layout area and the text box, wherein the layout type at least includes body text, title, header, footer, figure, figure caption, table, table caption, reference and formula; performing layered noise removal according to the layout type and noise rules such as page numbers, URLs, email addresses, copyright declarations, directory guide points and project symbols; horizontally merging adjacent text boxes in the same layout area, and performing vertical paragraph reconstruction according to horizontal overlapping, vertical spacing, punctuation continuation characteristics and breaking characteristics; identifying directory pages, hierarchical markers and list markers, and filtering edge fragments according to the proportion of the average width of column blocks and the page width.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent document processing technology, and in particular to a method and system for accurate extraction and structured reconstruction of PDF text content based on layout understanding. Background Technology

[0002] PDF parsing can typically obtain the text content and its coordinates, but objects such as body text, titles, headers and footers, figures, captions, table notes, references, and formulas are mixed in the same text stream. If processing is based solely on fixed thresholds, column geometry, or simple text boxes, it can easily lead to residual noise, lost body text, incorrect paragraph merging, and loss of source location traceability.

[0003] The key technical issues are: how to perform layered noise filtering based on page type annotation, how to combine break feature priority, punctuation continuation, horizontal overlap and vertical spacing to reconstruct paragraphs, how to preserve hierarchy and position labels, and how to handle OCR coordinate calibration, cross-page position labels, table and chart association and multi-column fragment filtering. Summary of the Invention

[0004] In view of the above problems, the present invention is proposed.

[0005] Therefore, this invention provides a method for accurate extraction and structured reconstruction of PDF text content based on layout understanding, which solves the problems of unclear layout type, incomplete noise filtering, unstable paragraph reconstruction, inability to trace back the position, and missing table and diagram relationships in PDF text extraction.

[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for accurate extraction and structured reconstruction of PDF text content based on layout understanding, including obtaining a set of text boxes carrying text content, page numbers and coordinate information in the PDF to be processed; Based on the degree of overlap between the candidate page area and the text box, each text box is labeled with a page type. The page type includes at least the main text, title, header, footer, figure, figure caption, table, table note, references and formula. Based on the layout type and preset noise rules, noise removal is performed on the text box. The noise rules include at least one of page number, URL, email, copyright statement, source label, table of contents guide point, garbled character mark and pure bullet line. Horizontally merge adjacent text boxes belonging to the same page area. When the vertical distance between adjacent text boxes is less than the preset proportion of the current page line height statistics, they are merged into the same line text box. Perform vertical paragraph reconstruction on adjacent text boxes, and determine whether adjacent text boxes belong to the same paragraph based on horizontal overlap, vertical center distance, current page line height statistics, punctuation continuation features and break features. Identify table of contents pages, table of contents entries, hierarchy markers, and list markers; clean up table of contents noise; preserve headings and list hierarchy; and prevent accidental merging of text boxes across hierarchy levels. The text boxes are aggregated into columns by horizontal position, and edge fragments are filtered based on the ratio of the average width of the column to the page width, the minimum width of the main text block, and the hit status of the hierarchical tags to support the reconstruction of the reading order of multi-column documents. Generate location labels containing page numbers and source coordinate ranges for each paragraph or line of text after reconstruction, enabling the output text to trace back to the source page and source area of ​​the original PDF.

[0007] As a preferred option, when the vertical center distance between adjacent text boxes is not greater than the product of the line height statistics and the vertical merging ratio, the horizontal overlap is not less than the product of the width of the smaller text box and the horizontal overlap ratio threshold, and the break feature is not triggered, adjacent text boxes are merged into the same paragraph.

[0008] As a preferred embodiment, the break feature includes at least one of the following: the previous text box ends with a sentence-ending punctuation mark, the page area changes, the vertical spacing exceeds a threshold, and the horizontal offset of the start point of the page crossover exceeds a threshold; the punctuation continuation feature includes at least one of the following: the previous text box ends with a comma or a colon, and the next text box begins with a right parenthesis or a continuing punctuation mark.

[0009] As a preferred embodiment, the location label records the source page number, left boundary, right boundary, top boundary, and bottom boundary in the format @@page number\x0\x1\top\bottom##; when the text box spans the bottom of the page, the location label is split into multiple coordinate segments corresponding to multiple page numbers.

[0010] As a preferred approach, when the input is a scanned PDF or an OCR text box, the OCR coordinates are first mapped back to the original PDF page coordinate system based on the rasterization scaling factor and page registration offset, and then page type annotation, noise removal, and paragraph reconstruction are performed.

[0011] As a preferred approach, table areas and image areas are separated from the text flow, and the nearest title, figure caption, or table note is associated based on the geometric distance between the text box and the table or image area. When adjacent pages of tables meet the requirements of similar header text fingerprints, consistent number of columns, and matching column width ratios, they are merged into a cross-page table.

[0012] As a preferred solution, when the page area detection fails, the text box coordinates are offset, the OCR results are garbled, or there are geometric rule conflicts, the error tolerance judgment is made according to the priority of page type, level mark, punctuation continuation, horizontal alignment, and language coherence.

[0013] Secondly, this invention provides a PDF text content accurate extraction and structured reconstruction system for layout understanding, including a layout type labeling module, a noise removal module, a horizontal merging module for the same layout, a vertical paragraph reconstruction module, a table of contents and hierarchy processing module, a column / block fragment filtering module, a location label and OCR calibration module, a table / chart extraction and title association module, and a fault tolerance module.

[0014] Thirdly, the present invention provides a computer device in which the processor executes a computer program to implement the above-described method.

[0015] Fourthly, the present invention provides a computer-readable storage medium on which a computer program stored is executed by a processor to implement the above-described method.

[0016] The beneficial effects of this invention are as follows: it establishes the basis for subsequent filtering and merging by labeling page layout types; it reduces erroneous merging across columns, levels, and paragraphs by using hierarchical noise rules, directory cleaning, hierarchical mark retention, and break feature priority; it enables traceability of output text back to the source PDF area by using location labels, OCR coordinate calibration, and cross-page label splitting; and it improves the integrity of structured reconstruction by separating tables and graphs and associating titles. Attached Figure Description

[0017] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 A flowchart illustrating a method for accurate extraction and structured reconstruction of PDF text content based on layout understanding.

[0019] Figure 2 A schematic diagram of a PDF text content extraction and structured reconstruction system based on layout understanding. Detailed Implementation

[0020] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0021] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0022] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.

[0023] Reference Figures 1 to 2 This is one embodiment of the present invention, which provides a method for accurate extraction and structured reconstruction of PDF text content based on layout understanding.

[0024] The system retrieves a set of text boxes containing text content, page numbers, and coordinate information from the PDF to be processed. The text boxes can originate from the PDF parsing results or from the OCR results; when they originate from OCR, coordinate scaling and page registration are performed first to map the OCR coordinates back to the original PDF page coordinate system.

[0025] The system labels the layout type based on the degree of overlap between the candidate layout area and the text box. Each text box is bound to one or more candidate types such as body text, title, header, footer, figure, figure caption, table, table footer, references, and formula.

[0026] The system performs layered noise removal based on layout type and noise rules. Noise rules include page numbers, URLs, email addresses, copyright notices, source attributions, table of contents introductory points, garbled text markers, and lines with only bullet points; the system retains the hierarchical markers for body text, headings, and list text.

[0027] The system performs horizontal merging on adjacent text boxes that belong to the same page area and whose vertical distance is less than the preset proportion of the current page line height, in order to fix the problem of the same line being fragmented.

[0028] The system performs vertical paragraph reconstruction on adjacent text boxes, comprehensively considering horizontal overlap, vertical center distance, line height statistics, punctuation continuation features, and break features to determine whether they belong to the same paragraph. Break features take precedence over continuation features and are used to prevent erroneous merging caused by sentence ends, page breaks, excessive spacing, or page offsets.

[0029] The system identifies directory pages, directory entries, heading level markers, and list markers, cleans up directory noise, preserves heading and list levels, and prevents accidental merging between text boxes across levels.

[0030] The system aggregates text boxes into columns based on their horizontal position and filters edge fragments based on the ratio of the average width of the column to the page width, the minimum width of the main text block, and the hit rate of the hierarchical markers, thereby supporting the reconstruction of the multi-column reading order.

[0031] The system generates location labels for each paragraph or line of text after reconstruction. The location labels record the page number and the source coordinate range. When a paragraph crosses the bottom of the page or spans multiple pages, it is split into coordinate segments corresponding to multiple page numbers.

[0032] The system separates table and image areas from the text flow and associates them with the nearest title, figure caption, or table caption based on geometric distance. For tables spanning multiple pages, they are merged based on the header text fingerprint, column count consistency, and column width ratio matching.

[0033] When the page area detection fails, the text box coordinates are offset, the OCR results are garbled, or there are geometric rule conflicts, the system makes a fault tolerance judgment according to the priority of page type, level mark, punctuation continuation, horizontal alignment, and language coherence.

[0034] In the vertical paragraph reconstruction, when the vertical center distance between adjacent text boxes is not greater than the product of the line height statistics and the vertical merging ratio, the horizontal overlap is not less than the product of the width of the smaller text box and the horizontal overlap ratio threshold, and the break feature is not triggered, the adjacent text boxes are merged into the same paragraph.

[0035] Furthermore, in the vertical paragraph reconstruction stage, the system first calculates the average line height m_h based on the height statistics of all text boxes on the current page, and takes a preset vertical merging ratio λ_y (1.5 in the embodiment), using |d_y(b,b')|≤λ_y·m_h as the vertical distance admission condition; at the same time, it calculates the horizontal overlap ov(b,b') between the two boxes, requiring it to be no less than λ_o times the width of the smaller text box (λ_o=0.5 in the embodiment), to ensure the continuity of the text block in the horizontal direction; finally, it checks whether the break feature Detach(b,b') is triggered - only when the vertical distance meets the standard, the horizontal overlap meets the standard, and no break feature is triggered, are the adjacent text boxes b and b' merged into the same paragraph. This joint judgment mechanism not only avoids the incorrect splitting of long paragraphs, but also prevents the incorrect adhesion of different logical paragraphs, especially suitable for complex scenarios such as cross-page continuation and multi-column layout.

[0036] The break feature includes at least one of the following: the previous text box ends with a sentence-ending punctuation mark, the page area changes, the vertical spacing exceeds a threshold, and the horizontal offset of the start point of the page exceeds a threshold; the punctuation continuation feature includes at least one of the following: the previous text box ends with a comma or a colon, and the next text box begins with a right parenthesis or a continuing punctuation mark.

[0037] Furthermore, the triggering conditions for the disconnection feature cover four typical scenarios: First, semantic paragraph termination signals, i.e., the previous text box ends with a period, question mark, exclamation mark, or other sentence-ending punctuation mark, without any subsequent semantic connection; second, changes in page layout logic, i.e., a switch in the page area type of adjacent text boxes (such as jumping from the main text to the footer, caption, etc.); third, abnormal geometric spacing, i.e., the vertical center distance exceeds the threshold of λ_y·m_h, or in the case of a cross-page scenario, the horizontal offset of the starting point of the next text box exceeds 1 / 10 of the page width, which does not conform to the text alignment rules of natural reading; and fourth, special structural blocks, such as text boxes containing independent structural identifiers such as hierarchical markers and table of contents guide points. The corresponding punctuation continuation feature is used to offset some interference from non-strong break signals: if the previous text box ends with a sentence-continuing punctuation mark such as a comma or colon, or the next text box begins with a connecting symbol such as a right parenthesis or "—", and there are no other strong break features, the spacing constraint can be weakened, and it can be preferentially judged as a continuation within the same paragraph, taking into account the writing characteristics of different punctuation systems in Chinese and English. The location labels use the format @@page number\x0\x1\top\bottom## to record the source page number, left boundary, right boundary, top boundary, and bottom boundary; when the text box spans the bottom of the page, the location labels are split into multiple coordinate segments corresponding to multiple page numbers.

[0038] Furthermore, the system adds standardized location labels to each line of reconstructed text, strictly following the format @@page number\tx0\tx1\ttop\tbottom##, where x0, x1, top, and bottom correspond to the left, right, top, and bottom boundary coordinates of the text box in the original PDF page coordinate system, respectively. This achieves a precise one-to-one mapping between the extracted text and the source location, supporting downstream needs such as evidence highlighting and region cropping. For the special scenario of spanning multiple pages, when the bottom coordinate of the text box, multiplied by the OCR rasterization scaling factor Z, exceeds the current page image height Img_h, the system automatically recalculates the coordinates using the formula bottom←bottom - Img_h / Z. Simultaneously, it appends a next page identifier to the page number sequence, splitting the original spanning text box into independent coordinate segments corresponding to the two page numbers. This ensures that each location label points to a valid coordinate range within a single page, avoiding cross-page coordinate boundary issues.

[0039] When the input is a scanned PDF or an OCR text box, the OCR coordinates are first mapped back to the original PDF page coordinate system based on the rasterization scaling factor and page registration offset, and then page type annotation, noise removal and paragraph reconstruction are performed.

[0040] Furthermore, when the input is a scanned PDF or a text box obtained through OCR recognition, the system first rasterizes the original page with a preset scaling factor Z (3 in this example) to improve the OCR recognition accuracy, obtaining preliminary text box coordinates based on the raster image coordinate system. Then, through methods such as page corner positioning, text dense area registration, or bounding box alignment, the system calculates the horizontal offset Δx and vertical offset Δy from the OCR raster coordinate system to the original PDF page coordinate system. All text box coordinates are mapped and calibrated according to the rules x0'=x0_OCR+Δx and top'=top_OCR+Δy to eliminate scaling and translation deviations in the OCR recognition process. The calibrated text boxes then enter the subsequent layout type labeling, noise removal, and paragraph reconstruction process, ensuring that the processing logic of scanned documents and editable PDFs is consistent and the coordinate accuracy of the extracted results is consistent.

[0041] The table and image areas are separated from the text flow, and the nearest title, figure caption, or table note is associated with the text box based on the geometric distance between it and the table or image area. When adjacent pages of tables meet the requirements of similar header text fingerprints, consistent number of columns, and matching column width ratio, they are merged into a cross-page table.

[0042] Furthermore, the system first separates text boxes labeled as tables and images from the main text flow to prevent text within table cells and text within figure captions from interfering with the reading order of the main text; then it calculates the Euclidean geometric distance between each title, figure caption, and table caption text box and the table / figure area (combining horizontal spacing dx and vertical spacing dy, denoted by D). 2 =dx 2 +dy 2 The system calculates and associates the nearest title / annotation with the corresponding table / figure object, forming a complete structured unit of "table / figure-title-annotation". For cross-page table scenarios, when table areas are detected on adjacent pages, the system extracts the first row of the table header text to generate a hash fingerprint, compares the text similarity between the two pages' headers, and simultaneously checks the consistency of the number of columns and the difference in column width ratio (in this example, the similarity threshold τ is set to 0.8). When all three conditions are met, the two pages' tables are merged into a single structured table, and the original page number and coordinate mapping are retained for each table segment. This solves the problem of cross-page tables being fragmented and also prevents table content from being mixed into the main text stream.

[0043] When page layout area detection fails, text box coordinates are offset, OCR results show garbled characters, or geometric rules conflict, error tolerance judgment is made according to the priority of page layout type, level mark, punctuation continuation, horizontal alignment, and language coherence.

[0044] Furthermore, for large-scale document library version update scenarios, the system supports incremental reconstruction at the page level: by comparing PDF version hashes or page content fingerprints, only newly added or modified pages are re-executed with adaptive threshold initialization, layout annotation, and paragraph reconstruction. The layout type annotation results, merged paragraphs, and position tags of unmodified pages are all reused, significantly reducing redundant calculation overhead. At the same time, the system has a built-in dynamic threshold adaptation mechanism: in the S200 stage, the current page's page width, DPI, line height distribution, text density, text box width distribution, and language type are statistically analyzed, and core parameters are automatically adjusted—for example, for narrow-page documents, the column block text judgment page width ratio η is reduced to avoid accidental deletion of short columns; for wide-page, multi-fragmented documents, the minimum text block width w_min is increased to enhance the filtering effect; for English documents, the English punctuation continuation rules are switched to avoid misjudging abbreviated periods as paragraph breaks. The entire process can adapt to the processing needs of different formats such as academic papers, financial reports, and legal documents without manual intervention.

[0045] This embodiment also provides a system, including a page type labeling module, a noise removal module, a horizontal merging module for the same page, a vertical paragraph reconstruction module, a directory and hierarchy processing module, a column fragment filtering module, a location label and OCR calibration module, a table and chart extraction and title association module, and a fault tolerance module.

[0046] This embodiment also provides a computer device and a computer-readable storage medium for implementing the above method steps.

[0047] In summary, the protection focus of this invention is page type labeling, layered noise filtering, horizontal and vertical reconstruction, layer preservation, location label backtracking, OCR calibration, table and graph association, and cross-page processing, rather than simply white space valley identification or minimum convex hull arbitration.

[0048] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for accurate extraction and structured reconstruction of PDF text content based on layout understanding, characterized in that, include: Retrieve a set of text boxes containing text content, page numbers, and coordinate information from the PDF to be processed; Based on the degree of overlap between the candidate page area and the text box, each text box is labeled with a page type. The page type includes at least the main text, title, header, footer, figure, figure caption, table, table note, references and formula. Based on the layout type and preset noise rules, noise removal is performed on the text box. The noise rules include at least one of page number, URL, email, copyright statement, source label, table of contents guide point, garbled character mark and pure bullet line. Horizontally merge adjacent text boxes belonging to the same page area. When the vertical distance between adjacent text boxes is less than the preset proportion of the current page line height statistics, they are merged into the same line text box. Perform vertical paragraph reconstruction on adjacent text boxes, and determine whether adjacent text boxes belong to the same paragraph based on horizontal overlap, vertical center distance, current page line height statistics, punctuation continuation features and break features. Identify table of contents pages, table of contents entries, hierarchy markers, and list markers; clean up table of contents noise; preserve headings and list hierarchy; and prevent accidental merging of text boxes across hierarchy levels. The text boxes are aggregated into columns by horizontal position, and edge fragments are filtered based on the ratio of the average width of the column to the page width, the minimum width of the main text block, and the hit status of the hierarchical tags to support the reconstruction of the reading order of multi-column documents. Generate location labels containing page numbers and source coordinate ranges for each paragraph or line of text after reconstruction, enabling the output text to trace back to the source page and source area of ​​the original PDF.

2. The method as described in claim 1, characterized in that: In the vertical paragraph reconstruction, when the vertical center distance between adjacent text boxes is not greater than the product of the line height statistics and the vertical merging ratio, the horizontal overlap is not less than the product of the width of the smaller text box and the horizontal overlap ratio threshold, and the break feature is not triggered, the adjacent text boxes are merged into the same paragraph.

3. The method as described in claim 2, characterized in that: The break feature includes at least one of the following: the previous text box ends with a sentence-ending punctuation mark, the page area changes, the vertical spacing exceeds a threshold, and the horizontal offset of the start point of the page exceeds a threshold; the punctuation continuation feature includes at least one of the following: the previous text box ends with a comma or a colon, and the next text box begins with a right parenthesis or a continuing punctuation mark.

4. The method as described in claim 1, characterized in that: The location labels use the format @@page number\x0\x1\top\bottom## to record the source page number, left boundary, right boundary, top boundary, and bottom boundary; when the text box spans the bottom of the page, the location labels are split into multiple coordinate segments corresponding to multiple page numbers.

5. The method as described in claim 1, characterized in that: When the input is a scanned PDF or an OCR text box, the OCR coordinates are first mapped back to the original PDF page coordinate system based on the rasterization scaling factor and page registration offset, and then page type annotation, noise removal and paragraph reconstruction are performed.

6. The method as described in claim 1, characterized in that: The table and image areas are separated from the text flow, and the nearest title, figure caption, or table note is associated with the text box based on the geometric distance between it and the table or image area. When adjacent pages of tables meet the requirements of similar header text fingerprints, consistent number of columns, and matching column width ratio, they are merged into a cross-page table.

7. The method as described in claim 1, characterized in that: When page layout area detection fails, text box coordinates are offset, OCR results show garbled characters, or geometric rules conflict, error tolerance judgment is made according to the priority of page layout type, level mark, punctuation continuation, horizontal alignment, and language coherence.

8. A system for accurate extraction and structured reconstruction of PDF text content based on layout understanding, characterized in that, It includes a page type labeling module, a noise removal module, a horizontal merging module for the same page, a vertical paragraph reconstruction module, a table of contents and hierarchy processing module, a column and block fragment filtering module, a location label and OCR calibration module, a table and chart extraction and title association module, and a fault tolerance module; The system is used to perform the method according to any one of claims 1 to 7.

9. 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, it implements the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.