Skip to content

find_tables() default (use_layout=True) misses ruled tables that use_layout=False finds #5225

Open

Description

@mgrabmayr

Description of the bug

With pymupdf-layout installed, Page.find_tables() in PyMuPDF 2.0 defaults to the layout-based finder (use_layout=True). On a set of born-digital service manuals with fully ruled tables (vector cell borders), that finder returns no table, while the line-based finder (use_layout=False, the 1.28.x behaviour) finds the full grid.

Across 36 affected pages from 8 PDFs:

tables found
PyMuPDF 1.28.2 find_tables() 36/36
PyMuPDF 2.0 find_tables() (default, layout) 1/36
PyMuPDF 2.0 find_tables(use_layout=False) 36/36

Example page: a 14×4 ruled table at bbox (89, 57, 561, 699). 1.28.2 → 14×4; 2.0 default → none; 2.0 use_layout=False → 14×4. pymupdf4llm.to_markdown(..., table_output="html") still emits the table on all 36 pages, so the layout model does recognise it there.

Bisect on that page under 2.0 default: removing any one of 7 text blocks restores detection (two large rotated watermark blocks in a condensed font, three cell texts that run past a column rule, two multi-line blocks in one column). Replacing all text with same-size x placeholders also restores it. So it looks like a combined or threshold condition, not one bad object.

Not reproduced synthetically: the following all detect correctly in both versions — filled-rect rules (black, grey, even-odd), stroked grid plus one rotated watermark, and a sweep of 0–2 watermarks × 0–10 overflowing cells. The source PDFs are confidential, so I cannot attach them; happy to run diagnostics locally.

How to reproduce the bug

import pymupdf
page = pymupdf.open("affected.pdf")[506]
print(len(page.find_tables().tables))                  # 2.0: 0
print(len(page.find_tables(use_layout=False).tables))  # 2.0: 1 (14x4)

PyMuPDF version

2.0 (pymupdf-layout 2.0, pymupdf4llm 2.0); compared against 1.28.2

Operating system

macOS

Python version

3.13

Activity

  1. JorjMcKie commented on Oct 29, 2026

    @JorjMcKie
    Collaborator

    Your submission is incomplete because you did not attach a reproducing file.
    This makes it impossible to deal with the issue. We will have to delete this issue after a grace period if no example is provided.

    You may use my private email address for submitting confidential files: jorj.x.mckie@outlook.de

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions