do_ocr=False yet text from embedded images is being extracted
Bug
When I run this extraction, text is being extracted from embedded images (i.e. images that are not selectable). I'm not running with OCR off, so I'm confused why this is being picked up?
Here is an example:
As you can see, the image, let alone the text within it, is not selectable. The PDF is found here if perhaps you can find text in it that I'm missing.
But the markdown output results in:
WARNING
LITHIUM ION BATTERY
REMOVE / INSTALL CAREFULLY
You can see this text is in the bottom left of the image.
What is happening and how do I disable this?
Steps to reproduce
pipeline_options = PdfPipelineOptions()
pipeline_options.do_ocr = False
pipeline_options.do_table_structure = True
pipeline_options.table_structure_options.do_cell_matching = True
pipeline_options.images_scale = 2.0
pipeline_options.generate_page_images = True
pipeline_options.generate_picture_images = True
converter = DocumentConverter(
format_options={
InputFormat.PDF: PdfFormatOption(pipeline_options=pipeline_options)
}
)
Docling version
Docling version: 2.58.0 Docling Core version: 2.49.0 Docling IBM Models version: 3.10.1 Docling Parse version: 4.7.0 Python: cpython-313 (3.13.5) Platform: macOS-15.7.2-arm64-arm-64bit-Mach-O
Python version
Python 3.13.5
Hi @nickreisner! I'm Dosu and I’m helping the docling team.
When do_ocr=False, Docling does not run OCR—so any text you see extracted from what looks like an image is actually coming from a hidden or overlay text layer in the PDF, not from OCR. Many PDFs (especially those generated by certain tools or for accessibility) include invisible text over images, which Docling extracts as normal text even if it isn't selectable in your PDF viewer. This is expected behavior: Docling always extracts all text from the PDF's text layer when OCR is off, regardless of whether that text is visible or selectable in a viewer (source, source).
To prevent this, you would need to preprocess the PDF to remove hidden or overlay text (using tools like Adobe Acrobat, qpdf, or mutool). There is no Docling option to ignore or filter out hidden text when OCR is disabled.
If you want to guarantee that OCR is never run and only the PDF's text layer is used, use do_ocr=False and the PyPdfiumDocumentBackend (source). But if the PDF contains hidden text, Docling will still extract it.
If you want to inspect your PDF for hidden text, try selecting all content on the page in a PDF viewer, or use command-line tools like pdftotext or mutool show to dump the text layer and see what Docling will extract.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
This works amazingly! The PyPdfiumDocumentBackend was the solution.