docling-project / docling-project/docling
Getting word-level bounding boxes from DocumentConverter
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
Hi!
I'm exploring methods to generate word-level bounding boxes for both OCR'd and programmatic content within PDFs using the main `docling.DocumentConverter` pipeline.
I'm considering a hybrid strategy, and I'd appreciate any insights or alternative suggestions:
1. **For OCR'd Content**: Is it feasible to modify/configure the `OcrOptions` (e.g., `TesseractOcrOptions`, `EasyOcrOptions`) within the `DocumentConverter` pipeline to instruct the underlying OCR engines to return word-level bounding boxes? The goal would be for Docling to then preserve and expose this detailed output.
2. **For Programmatic Content**: Since `docling-parse` is already used in the Docling PDF conversion and can provide word-level granularity (e.g., `TextCellUnit.WORD`), could the `DocumentConverter` pipeline be enhanced to expose these word-level bounding boxes derived from `docling-parse` in the final `DoclingDocument`? This might involve adjustments to how `Provenanceltem` or `TextItem` structures currently store or represent this information.
Essentially, the idea is to leverage the native capabilities of OCR engines for scanned parts and `docling-parse` for programmatic parts, all through the main Docling pipeline. This way, I could use the same pipeline for programmatic, OCR and mixed pdfs. Is this approach a viable path, or are there other existing/recommended methods to achieve word-level bounding box output?
Contributor guide
Assessment
This issue has not been assessed yet.