docling-project / docling-project/docling
Complex Table Conversion Issue (Wrong order, key-value regions)
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
### Bug
* Out of order conversion: it would be nice if headers(UNCLASSIFIED , American Football Conference (AFC) , AFC East) appear after text fields
* Keys missing their values: the text fields have values, but it is all separated by newlines in the text output. it would be amazing if the text fields had their values more closely associated (something like Code: DLPHN instead of what the output currently shows)
### Steps to reproduce
```
import os
from docling.datamodel.base_models import InputFormat
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.pipeline_options import PdfPipelineOptions, TableFormerMode
from pathlib import Path
source = "input/complex table.pdf"
pipeline_options = PdfPipelineOptions(do_table_structure=True)
pipeline_options.table_structure_options.do_cell_matching = True # uses text cells predicted from table structure model
pipeline_options.table_structure_options.mode = TableFormerMode.ACCURATE
doc_converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
}
)
result = doc_converter.convert(source)
## Export results
output_dir = Path("resultconversion")
output_dir.mkdir(parents=True, exist_ok=True)
doc_filename = result.input.file.stem
# Export Text format:
with (output_dir / f"{doc_filename}.txt").open("w", encoding="utf-8") as fp:
fp.write(result.document.export_to_text())
```
[complex input table.pdf](https://github.com/user-attachments/files/17666659/complex.input.table.pdf)
[complex output table.txt](https://github.com/user-attachments/files/17666660/complex.output.table.txt)
### Docling version
2.4.0
### Python version
3.12.4
Contributor guide
Assessment
This issue has not been assessed yet.