docling-project / docling-project/docling

wrong text order in paragraph

Open
#2,016 1 comment 0 reactions 0 assignees View on GitHub
bug reading_order triage/close-stale
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Bug

A [challenging PDF](https://avys.omu.edu.tr/storage/app/public/seden.dogan/129943/tour%20book%20India.pdf) has a very complicated object layer/construction and on page 7 are a number of paragraphs like this, all of which are rendered in the wrong order:

Image

### Steps to reproduce
```python
converter = DocumentConverter()
result = converter.convert("https://avys.omu.edu.tr/storage/app/public/seden.dogan/129943/tour%20book%20India.pdf")
doc = result.document

print(doc.export_to_markdown(page_no=7))
```

Note this text:
> , the open air art gallery of Rajasthan, is a quaint village in the heart of Shekhawati region. Mandawa has preserved fine examples of frescoes and painted havelis, as masterpieces of art from bygone era. MANDAWA

But it should be:
> MANDAWA, the open air art gallery of Rajasthan, is a quaint village in the heart of Shekhawati region. Mandawa has preserved fine examples of frescoes and painted havelis, as masterpieces of art from bygone era.

The "MANDAWA" is at the end of the line, rather than at the front.

Using (default) OCR does not resolve the problem:

```python
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_options=PdfPipelineOptions(
do_ocr=True,
force_full_page_ocr=True,
)
)
}
)
result = converter.convert("https://avys.omu.edu.tr/storage/app/public/seden.dogan/129943/tour%20book%20India.pdf")
```

### Docling version
```
phil@Phils-MacBook-Pro docling % uv run docling --version
Docling version: 2.43.0
Docling Core version: 2.43.1
Docling IBM Models version: 3.9.0
Docling Parse version: 4.1.0
Python: cpython-312 (3.12.10)
Platform: macOS-15.5-arm64-arm-64bit
```

### Python version
```
phil@Phils-MacBook-Pro docling % uv run python --version
Python 3.12.10
```

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.