docling-project / docling-project/docling

Incorrect Line Splitting in Table Cell Extraction

Open
#1,611 1 comment 0 reactions 1 assignee Claimed by @maxmnemonic View on GitHub
bug table structure
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Bug

When extracting tables from the attached PDF (_wrong_cell.pdf_) using Docling, I noticed that text from the final line of a paragraph in a multi-page table cell incorrectly flows into the next cell during extraction. As a result, the extracted output (_wrong_cell.md_) does not accurately represent the original table structure, and cell boundaries are not preserved.

This issue occurs in the specific example attached. In other cases, Docling handles table cell extraction correctly.

### Steps to reproduce

1. Run Docling on the attached wrong_cell.pdf.
2. Check the output.
3. Notice that the last line of a paragraph from a multi-page cell appears in the next cell, instead of remaining in the original cell.

```
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions, TableFormerMode
from docling.document_converter import DocumentConverter, PdfFormatOption

def extract_data_with_docling(input_data_path):
pipeline_options = PdfPipelineOptions(do_table_structure=True)
pipeline_options.table_structure_options.mode = TableFormerMode.ACCURATE

doc_converter = DocumentConverter(
allowed_formats=[InputFormat.PDF, InputFormat.IMAGE],
format_options={
InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
},
)

result = doc_converter.convert(input_data_path)
markdown_content = result.document.export_to_markdown()
print(markdown_content)

extract_data_with_docling("PDF PATH")
```

### Docling version

Docling version: 2.31.0
Docling Core version: 2.28.1
Docling IBM Models version: 3.4.1
Docling Parse version: 4.0.0

### Python version

Python 3.10.11

[wrong_cell.md](https://github.com/user-attachments/files/20299205/wrong_cell.md)
[wrong_cell.pdf](https://github.com/user-attachments/files/20299204/wrong_cell.pdf)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.