docling-project / docling-project/docling

Unable to get correct reading order for a standard two-column pdf

Open
#2,204 2 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Bug
For some two-column pdfs, docling is interpreting the reading order incorrectly.

Example two-column pdf: http://algos.inesc.pt/projects/lapa/icml00-algsel2000.pdf

When I use docling to extract the markdown with the default conversion parameters, it reads in the title/authors, abstract, introduction heading, then hops over to the next column before finishing the first (left) column. As a result, the Introduction section is all out of order. Specifically, I get:

```
## 1. Introduction

A challenging research goal is to design a run-time system...

Recall that a recursive algorithm...

cheaper, Related work (Lobjois & Lemaˆ ıtre, 1998; Fink, 1998)...

The remainder of this section...

When performing a repetitive task...
```

I had previously asked this issue as a question [here](https://github.com/docling-project/docling/issues/2201), but am now opening this as a bug report because it seems like it cannot be easily fixed with user-facing parameters. However, I feel this is something that should work, as this pdf was correctly parsed by other pdf to text converters (e.g. pymupdf, pdfminer, docstrange).

### Steps to reproduce
I get the same issue with all the docling layout models (Heron, Layout v2, all of the Egrets). Here is how I am setting the layout model:

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

source = "/path/to/file.pdf"

pipeline_options = PdfPipelineOptions()
pipeline_options.layout_options.model_spec = DOCLING_LAYOUT_V2
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
}
)
result = converter.convert(source)
text = result.document.export_to_markdown()
```

### Docling version
Docling version: 2.50.0
Docling Core version: 2.45.0
Docling IBM Models version: 3.9.1
Docling Parse version: 4.2.3

### Python version
Python 3.10.18

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.