docling-project / docling-project/docling

Docling_Parse: Spacing and Formatting Issues in German PDF Output

Open
#1,042 7 comments 0 reactions 1 assignee Claimed by @PeterStaar-IBM View on GitHub
bug pdf parsing
Dominant language
Python
Stars
66.4k
Forks
4.8k
Avg merge
2d 21h
Merged PRs (30d)
84

Description

### Bug
When converting pdf with German texts using Docling_Parse methods (both with and without EasyOCR), the resulting Markdown output contains unexpected spacing and formatting issues. Specifically, extra spaces and improper word splits appear in headers and body text, degrading readability and causing inconsistencies compared to the original PDF content.

Step-by-Step Comparison
**Header Detection & Formatting**
- **PyPdfium_without_EasyOCR / PyPdfium_with_EasyOCR:**
Both variants reliably detect headers and generate proper Markdown headers (e.g. “## Rheumatoide Arthritis”, “## Schmerzmittel bei rheumatoider Arthritis”). In our sample, these headers are clearly delineated with the “##” Markdown syntax.
- **Docling_Parse_without_EasyOCR / Docling_Parse_with_EasyOCR:**
These outputs show degraded header formatting. Instead of clear “##” markers, the text appears with inconsistent spacing and broken words, losing the clear distinction between header and body text.

**Text Accuracy**
- **PyPdfium Methods:**
They reproduce the text in a clean manner.
- **Docling_Parse Methods:**
The extracted text includes artifacts like unwanted spaces and split words (e.g. “E ntzündungshemmende S chmerzmittel” instead of “Entzündungshemmende Schmerzmittel”), which degrade the overall readability and structure.

**Original source file:**

![Image](https://github.com/user-attachments/assets/fcd2259b-5834-4946-b947-0260d8604231)

**Outputs for Docling_Parse_without_EasyOCR**

```

Rheumatoide Arthritis

Schmerzmittel bei rheumatoider Arthritis

E ntzündungshemmende S chmerzmittel und K ortison können R heum a beschwerden lindern. S ie schützen a ber nicht v or G elenksch ä den. S ie eignen sich, um a kute S chmerzen zu lindern und die Z eit zu überbrücken, bis die W irkung kr a nkheitsmodifizierender M ittel einsetzt.
```

**Short Note:** For other tested PDFs, the Docling_Parse methods produced cleaner, more consistent Markdown output compared to the PyPdfium methods.

### Steps to reproduce
1. Run the conversion using Docling_Parse without EasyOCR.
2. Optionally, run the conversion using Docling_Parse with EasyOCR.
3. Observe that the output contains:
- Unintended extra spaces within words and punctuation.
- Incorrect splitting of headers and body text.

### Expected behavior
The converted Markdown should accurately reflect the original PDF's formatting, with:
- Properly merged headers.
- Consistent spacing throughout the text.
- No unexpected word splits or additional spaces.

### Docling version
Docling v2.24.0

### Python version
Python 3.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.