Layout analysis
Document layout analysis · Page segmentation
Finding the regions on a page and labeling each one, such as heading, paragraph, table, figure, caption or footer, before reading the text inside them.
In DocSlurpIllustrated explainer
On this page
The problem: everything on the page is text
Page 12 of growth-plan-2027.pdf has a heading, two paragraphs, a table of margin targets, an expansion diagram with a caption, and a running footer: “Confidential · Growth plan FY2027 · Page 12”.
Run a plain text extractor over it and every one of those becomes the same thing, a run of words. The table turns into one long line, “Metric Plan Forecast Ahead Revenue $43.0M $48.2M 12% Operating margin 20% 24% 4 pts”. The diagram’s labels (“New York”, “London”, “Q2 2027”) land in the middle of a paragraph. The footer appears on all 40 pages, so 40 chunks now contain the words “Confidential” and “Growth plan”, and any query mentioning the plan matches all of them a little.
Each word was extracted correctly. What went wrong is that nothing knew what kind of thing each word belonged to.
What layout analysis does
Layout analysis finds the regions on a page and labels each one before anyone reads the text inside. The output is a list of boxes, each with a label and usually a confidence:
| Region | Label | What the pipeline does with it |
|---|---|---|
| “4.2 Margin plan” | section heading | starts a new section; becomes the heading path of later chunks |
| Two text blocks | paragraph | ordinary text, chunked normally |
| Grid of cells | table | sent to table extraction |
| Diagram | figure | captioned, described by a vision model, or skipped |
| “Figure 3: Expansion timeline” | caption | attached to its figure |
| “Confidential · … · Page 12” | page footer | dropped from the text, kept as metadata |
The labels decide how each region is handled. That is the whole point: different regions need different extractors, and some need none.
Two ways to find regions
Rules over geometry. If the PDF has a text layer, every word already has a position, a font and a size. Simple rules go a long way. Larger, bolder text on its own line is probably a heading. Text that repeats at the same position on every page is a header or footer. One concrete rule set, used by DocSlurp’s native PDF engine, classifies a block by where its center falls:
- center in the top 10% of the page height: header
- center in the bottom 10%: footer
- center in the outer 15% of the width: left or right sidebar
- anything else: body
On a US Letter page (612 × 792 points, with y measured down from the top) that means a header above y = 79.2, a footer below y = 712.8, and sidebars left of x = 91.8 or right of x = 520.2. A footer line centered at y = 760 is a footer; a margin note centered at x = 50 is a left sidebar.
Learned detectors. Rules need a text layer and a conventional design. A learned detector works on the page image instead. It is an object-detection model, the same kind that finds cars in photos, trained on pages where people drew and labeled boxes. DocLayNet, a widely used training set, has about 80,000 pages labeled with 11 classes: caption, footnote, formula, list item, page footer, page header, picture, section header, table, text and title. Because it looks at pixels, a detector works on scans as well as born-digital PDFs.
Most production systems mix the two: a detector proposes regions and the text layer supplies exact words and positions inside them.
Where it breaks
- Unusual designs. Rules assume conventions. A report whose title sits in the top 10% of page 1 gets labeled “header” and dropped. A full-bleed photo with text over it confuses both approaches.
- Training-set mismatch. A detector trained on papers and annual reports has seen few receipts, slides or forms. It will still output boxes with confident labels; they will just be wrong more often.
- Borderless tables. A table with no ruling lines looks a lot like several narrow paragraphs. If the detector misses it, the cells are read as prose.
- Overlaps and splits. Boxes can overlap, or one paragraph can be split into two. A table that continues onto the next page is detected as two unrelated tables.
- Labels are not order. Knowing that a page has two paragraph regions side by side does not say which to read first. That is reading order, the next step.
When it matters
For a novel or a plain memo, layout analysis adds little: one column of paragraphs, no tables. It earns its cost on reports, papers, manuals, forms and slides, where structure carries meaning. The cheapest wins usually come first: drop repeated headers and footers, keep headings for chunking, and route tables and figures to specialists. A page-level decision about which pages need the expensive treatment is page routing.
In DocSlurp
In DocSlurp
No single layout model runs on every page. When a PDF has table pages, or a project enables pdfRegionExtraction, extraction also runs Unstructured's hi_res partitioner, which uses a layout detection model (core/worker/src/stages/extract-markdown.ts). The native PDF engine, when installed, classifies blocks as header, footer, sidebar or body by position (core/worker/src/native-pdf/regions.ts).