Skip to content

fix(pdf): keep layout-table words as text when tables are off - #1142

Merged
artiz merged 2 commits into
docling-project:masterfrom
BlackWolfNews:fix/tables-off-keeps-text
Nov 18, 2026
Merged

artiz merged 2 commits into
docling-project:masterfrom
BlackWolfNews:fix/tables-off-keeps-text

Conversation

@BlackWolfNews

Copy link
Copy Markdown
Contributor

--no-table-former / --no-tables is docling's do_table_structure=False. Layout still runs. A region it marked as a table was reconstructed with the geometric grid, and the words inside it left the text list. Those regions are now released before the containment drop, so the words stay text items, each with its own box.

The geometric grid remains when TableFormer was requested and its model files are missing, and in the browser build, which has no TableFormer.

The regression is an anonymized Texas oversize permit, crates/docling-pdf/tests/data/tx_osow_anonymized.pdf. The company-name section and the repeated copies of that name are blank. Axle: and Miles, which the grid used to swallow, come back as located text.

Ran on rustc 1.100.0:

cargo test --lib --tests -p docling-core -p docling -p docling-asr -p docling-serve -p docling-pdf

and on the CI lint toolchain 1.96.0:

cargo fmt --all --check
cargo clippy --workspace --all-targets -- -D warnings

The PDF snapshot harness was not run (no ONNX models in this checkout). This path runs only when table structure is off, so the TableFormer-on baselines should not move. docs/PDF_CONFORMANCE.md is unchanged.

`--no-table-former` / `--no-tables` is docling's do_table_structure=False.
Layout still runs. A region it marked as a table was reconstructed with
the geometric grid, and the words inside it left the text list. Release
those regions before the containment drop so the words stay text items,
each with its own box.

The geometric grid stays when TableFormer was requested and its model
files are missing, and in the browser build, which has no TableFormer.

The regression is an anonymized Texas oversize permit
(tests/data/tx_osow_anonymized.pdf). The company-name section and the
repeated copies of that name are blank. Axle and Miles, which the grid
used to swallow, come back as located text.

Ran on rustc 1.100.0:

    cargo test --lib --tests -p docling-core -p docling -p docling-asr \
        -p docling-serve -p docling-pdf

and on the CI lint toolchain 1.96.0:

    cargo fmt --all --check
    cargo clippy --workspace --all-targets -- -D warnings

PDF snapshots were not regenerated. This path runs only when table
structure is off, so the TableFormer-on baselines should not move.

Signed-off-by: BlackWolf <github@dungbusters.com>
@artiz

artiz commented Nov 18, 2026

Copy link
Copy Markdown
Member

Thanks, keeping these words is a real improvement over the grid swallowing them. A few things before merging:

  1. docling 2.150’s do_table_structure=False emits an empty table (PageAssembleModel, text="", no cells), not text. Please describe this as a deliberate divergence in the comments and docs, and list it in MIGRATION.md’s divergences.
  2. The permit PDF still has the permit number, US DOT number, plate and route. Please scrub them, or use a synthetic layout.
  3. On a scanned page the table region is gone before OCR, so without ocr_det.onnx its text is lost. Could you release the regions after OCR, and add a scanned-page test?

crates/docling-pdf/src/lib.rs

        // `do_table_structure=False`: no TableFormer and no geometric grid.
        // ...
        if self.tables.is_none() {
            assemble::release_unstructured_tables(&mut regions);
        }
...

crates/docling-pdf/src/assemble.rs

/// [`release_unstructured_tables`] once OCR has read the page: drop the table
/// regions, give their words — which nothing claims any more — orphan text
/// regions, and re-run the containment drop. On a digital page the words are
/// the text layer's; on a scan, the `ocr_table_words` crops OCR made while
/// the table regions still existed.
pub fn release_unstructured_tables_after_ocr(regions: &mut Vec<Region>, cells: &[TextCell]) {
    if !regions.iter().any(|r| is_table_like(r.label)) {
        return;
    }
    release_unstructured_tables(regions);
    add_orphan_regions(regions, cells);
    drop_contained_regulars(regions);
}
  1. Please add a test for the Worker gate, both with tables off and with the model missing, and update serve’s openapi.yaml and index.html descriptions.

artiz

This comment was marked as duplicate.

@artiz artiz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...

docling 2.150 still emits an empty table when structure is off. This
port keeps the words as text, and the comments and MIGRATION.md now
call that a deliberate divergence.

The table region stays through OCR, so a scanned page's table crop is
read before the region is dropped. Releasing it first lost those words
when the text detector was absent.

The permit fixture no longer carries the permit number, US DOT number,
plate, VIN, or route. Tests cover the worker with tables off and with
TableFormer missing, and a scanned page whose only words came from the
table crop.

Signed-off-by: BlackWolf <github@dungbusters.com>
@BlackWolfNews

Copy link
Copy Markdown
Contributor Author

Addressed the four points in ed55070.

  1. The empty-table behavior is documented as a deliberate divergence from docling 2.150 (PageAssembleModel, text="", no cells), including MIGRATION.md §4 item 28.
  2. The fixture no longer contains the permit number, US DOT number, plate, VIN, or route. Axle: and Miles are still the regression words.
  3. Table regions are released after OCR (release_unstructured_tables_after_ocr), with a scanned-page test for the table-crop words.
  4. Worker tests cover tables off and a missing TableFormer model. openapi.yaml and index.html no longer describe this flag as geometric reconstruction.

@artiz
artiz merged commit 89715bc into docling-project:master Nov 18, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants