A fixture with no text layer
Every PDF used so far, quarterly_report.pdf, research_note.pdf, had a real text layer: the PDF format itself stores the characters, docling just reads them. scanned_invoice.pdf is different on purpose, it's a picture of an invoice saved as a PDF, the same shape a phone-camera photo or a flatbed scan produces. There is no text layer at all, only pixels. This is exactly the case OCR exists for.
Proving it with do_ocr=False
options = PdfPipelineOptions()options.do_ocr = FalseConverting scanned_invoice.pdf with OCR turned off extracts nothing, export_to_text() comes back empty. This isn't a bug, there's genuinely no text for docling to read without recognizing it from the image first.
do_ocr=True, the default you've been using all along
Every prior lesson's DocumentConverter() already had do_ocr=True, it just never mattered because those PDFs had text layers OCR wasn't needed for. On scanned_invoice.pdf, it's the only thing that produces output: docling's default OCR engine runs over the page image, recognizes the characters, and inserts them back into the document structure at the position they were found, so the recognized text still participates in the same DoclingDocument structure as text read from a native layer.
Recognized text from a real scan is rarely perfect (misread digits, merged words), that's the nature of OCR, not a docling-specific limitation. docling also supports pointing ocr_options at a specific engine (EasyOCR is the default, Tesseract and RapidOCR are both available as alternatives) when you need to match a particular engine's accuracy or licensing profile, this lesson sticks to the default to keep the comparison to exactly one variable: OCR on or off.
Checkpoint
- Not every PDF has a text layer: scanned or photographed pages are images, with nothing for a non-OCR reader to extract.
do_ocr=Trueis the default: every earlier lesson already ran with OCR enabled, it just had nothing to do on PDFs with real text layers.- OCR output is approximate: useful for search and rough extraction, not a substitute for verifying exact numbers by hand.
- Multiple OCR engines are available: EasyOCR by default, with Tesseract and RapidOCR as configurable alternatives via
ocr_options.
If anything here still feels unclear, ask before moving to Lesson 10.