docling-project / docling-project/docling
docling parsing for scanned pdfs wont detect white space between words.
- Dominant language
- Python
- Stars
- 66.4k
- Forks
- 4.8k
- Avg merge
- 3d 4h
- Merged PRs (30d)
- 95
Description
### Bug
When i use docling and rapidocr to parse the pdfs. There are no spaces between words. so instead of this is the parsed response, it would be something like thisistheparsed response, at first i thought it was just one pdf, but happens for basically any or most of the pdf that are scanned, the quality is pretty clear, still i'm getting this error. I don't want to change to easyocr, cause that doesn't work with complex layouts as good as rapidocr.
[financial_reports_8.pdf](https://github.com/user-attachments/files/23691645/financial_reports_8.pdf)
### Steps to reproduce
Nothing crazy here, just the standard code:
```
from docling.document_converter import DocumentConverter, PdfFormatOption
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PdfPipelineOptions, RapidOcrOptions
from docling.datamodel.accelerator_options import AcceleratorDevice, AcceleratorOptions
from docling.datamodel.pipeline_options import (
ThreadedPdfPipelineOptions, AcceleratorOptions, AcceleratorDevice
)
import time
pipeline_options = PdfPipelineOptions()
pipeline_options.do_ocr = True
pipeline_options.ocr_options = RapidOcrOptions(
backend="openvino",
)
accelerator_options = AcceleratorOptions(
num_threads=6, device=AcceleratorDevice.CUDA
)
pipeline_options.accelerator_options = accelerator_options
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(
pipeline_options=pipeline_options,
)
}
)
start = time.time()
result = converter.convert("dataset/ocr/record1.pdf")
markdown = result.document.export_to_markdown()
duration = time.time()-start
print(duration)
```
### Docling version
Docling Version: 2.62.0
### Python version
Python Version: 3.9.12
### sample parsed output:
## notestoconsolidatedfinancialstatements
## Note23:ContingentLiabilities
We have been named in various lawsuits and intend to vigorously defend ourselves. While we cannot predict the outcome of these lawsuits, we believe thesematterswillnot have amaterial adverse effecton ourfinancial position, resutts ofoperations or cash flows.
Cosmetics.We were originally named as a defendant along with other department store and specialty retailers in nine separate but virtually identical classactionlawsuitsfiled invariousSuperior CourtsoftheStateof Californiain May.June and July 1998thathave nowbeen consolidated in Marin County state court.InMay 2000,plaintiffs filed an amended complaint naming a number of manufacturers of cosmetics and fragrances and two other retailers as additional defendants.Plaintiffs'amended Store"cosmetics sold in department and specialty storeswas collusively controlledbytheretailerandmanufacturerdefendants inviolation of theCartwrightActand theCaliforniaUnfairCompetitionAct.
Plaintiffs seek treble damages and restitution in an unspecified amount, attorneys'feesandprejudgmentinterest,on behalfofaclassofall California residentswho purchased cosmetics and fragrancesforpersonal usefromanyofthedefendantsduring theperiodfouryearsprior to the filing of the amended complaint.Defendants,including us,have answered the amended complaint denying the allegations. The defendants have produced documents and responded to plaintiffs' other discovery requests, including providing witnesses for depositions.
Weentered intoasettlementagreementwiththeplaintiffsand theother defendants on July 16,2003.In furtherance of the settlementagreement, thecasewasrefiled in theUnitedStatesDistrict Courtfor the Northern District of California on behalf of a class of all persons who currently reside in theUnitedStatesand whopurchased"DepartmentStorecosmetics fromthedefendantsduringtheperiodMay29.1994throughJuly16, 2003.The Court hasgivenpreliminary approval to the settlement.A summarynoticeofclasscertificationand thetermsof thesettlementhas been disseminated to class members.Ahearing on whether the Court willgrantfinalapprovalof thesettlementisscheduledforJune8,2004. IfapprovedbytheCourt,thesettlementwillresultintheplaintiffs'claims and the claims of all class members being dismissed, with prejudice,in theirentirety.In connectionwith thesettlement agreement, the defendants attormeys'fees. Our share of the cost of the settlement will not have a material adverseeffectonourfinancialcondition.
WashingtonPublicTrustAdvocates.Inearly 2002,wewerenamed asone of 30 defendants in Washington Public Trust Advocates, ex rel., et al. v. City ofSpokane,etal.,filed intheSpokaneCountySuperiorCourt,Stateof Washington.Plaintiff is a not-for-profit corporation bringing claims on Authority.Theclaimsrelate to theRiverParkSquare Malland Garage Project in Spokane,Washington (the"Project"],which includes a Nordstrom store.The portion ofthe complaint applicable to us seeks to recover from us the amount of a Department of Housing and Urban Development (HUD") loanmade to the developerof theProject.Damagesare sought in theamountof$22.75million,oralesseramounttotheextentthatthe HuDloanproceedswereusedfor theconstructionofthestoreandnot as tenant improvements.Other portions of the complaint seek to invalidate bonds issued to finance the public parking garage serving the Project, terminate agreements between the City of Spokane and the developer of the Project, amounts.The Complaintalsoallegesbreach of fiduciary dutiesbyvarious defendants,including us, to the people of the City of Spokane regarding lack of disclosures concerning the developer and the Project. By order datedAugust 9,2002,the court granted our motion todismissus from that lawsuit.Plaintiff attempted to obtain directreviewby theWashingtonSupreme Courtwhich declined tohear thecase andreferredit to theWashington Court of Appeals. On May 20, 2003, the Washington Court of Appeals affirmed our dismissal.
### Bug
I've heard very good reviews about docling, and i'm wondering if i am doing something wrong perhaps ? i looked through the issues, didn't find anything. either i'm unlucky enough to run into this issue or naive enough to get it wrong...
Please help, i really need this sorted for my project. (also attaching the pdfs so that you could run that and verify)
Contributor guide
Research direction
Reproduce the issue with the attached financial_reports_8.pdf using DocumentConverter, PdfPipelineOptions, and RapidOcrOptions with the configuration shown. Compare the exported Markdown with the sample output and trace how OCR text is assembled; done means scanned PDF words retain appropriate spaces without switching away from RapidOCR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100