docling-project / docling-project/docling
Text Extraction Errors with Turkish Characters in Digital PDFs
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 84
Description
Bug
Hello Docling Team,
First of all, thank you for developing this powerful and versatile document processing library.
I am using docling to parse legal documents in Turkish. These are digitally-born PDFs, not scanned images. I have encountered a specific text extraction issue where words containing Turkish characters (like ş, ı, ğ, ü, ö, ç) are incorrectly parsed with spaces inserted between letters.
Interestingly, this issue only occurs in certain sections of the PDF. In other parts of the same document, the text is extracted perfectly.
For example, the Turkish word "Rüşvet" (meaning bribery) is incorrectly extracted as "R üş vet".
The source PDF itself is clean. When I copy-paste the text directly from a PDF viewer, it is perfectly correct. There are no visible formatting differences in the original document, which suggests the issue is in the parsing logic rather than the source file.
I have attached a sample PDF for your review. The problem is particularly noticeable on Page 69 (Article 277) and Page 72 (Article 285).
Thank you for your attention to this matter.
Very respectfully,
AirMaster
Steps to reproduce
Save the attached Turkish legal PDF document.
Run the following minimal Python script to extract text from a specific page (e.g., page 69).
code
Python
from docling.document_converter import DocumentConverter
from pathlib import Path
PDF_FILE = "YOUR_PDF_FILENAME.pdf" # <-- Replace with the name of the attached PDF
TARGET_PAGE_NUM = 69
converter = DocumentConverter()
doc = converter.convert(Path(PDF_FILE)).document
# Helper function to get all text from a specific page
def get_text_from_page(doc_obj, page_num):
page_texts = []
target_page_index = page_num - 1
for item in doc_obj.texts:
if hasattr(item, 'prov') and item.prov and item.prov[0].page_no == target_page_index:
page_texts.append(item.text)
return "\\n".join(page_texts)
# Extract and print the text from the target page
page_content = get_text_from_page(doc, TARGET_PAGE_NUM)
print(page_content)
Observe the output text. You will notice incorrect spacing within words containing Turkish characters, such as G ö revinin, ifas ı yla, R üş vet, etc.
Docling version
2025-10-13 08:47:22,585 - INFO - Loading plugin 'docling_defaults'
2025-10-13 08:47:22,590 - INFO - Registered ocr engines: ['easyocr', 'ocrmac', 'rapidocr', 'tesserocr', 'tesseract']
Docling version: 2.55.1
Docling Core version: 2.48.4
Docling IBM Models version: 3.9.1
Docling Parse version: 4.5.0
Python: cpython-313 (3.13.5)
Platform: Windows-11-10.0.26100-SP0
Python version
Python 3.13.5
[19820191510085237 Sayılı Türk Ceza Kanunu.pdf](https://github.com/user-attachments/files/22877402/19820191510085237.Sayili.Turk.Ceza.Kanunu.pdf)
Contributor guide
Assessment
This issue has not been assessed yet.