are there any specific settings that i have to enable inorder to get the text from images? give me a code snippet
are there any specific settings that i have to enable inorder to get the text from images?
the below code is unable to extract text from the images which are there in the ppt
from docling.document_converter import DocumentConverter source = "22804.pptx" # Local file or URL converter = DocumentConverter() result = converter.convert(source) print(result.document.export_to_markdown())
To extract text from images in PPTX files with docling, you need to make sure OCR is enabled. By default, OCR is on, but for some files (especially if the images are not detected as needing OCR), you may need to force it. You can do this by setting the appropriate pipeline options for PPTX. Here’s an example:
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import EasyOcrOptions, PipelineOptions
from docling.document_converter import DocumentConverter, FormatOption
from docling.backends.powerpoint import MsPowerpointDocumentBackend
from docling.pipelines.simple_pipeline import SimplePipeline
ocr_options = EasyOcrOptions(force_full_page_ocr=True, do_ocr=True)
pipeline_options = PipelineOptions(ocr_options=ocr_options)
pptx_format_option = FormatOption(
pipeline_cls=SimplePipeline,
backend=MsPowerpointDocumentBackend,
pipeline_options=pipeline_options
)
converter = DocumentConverter(
format_options={InputFormat.PPTX: pptx_format_option}
)
result = converter.convert("22804.pptx")
print(result.document.export_to_markdown(image_mode="placeholder"))
Make sure you have an OCR engine installed (like EasyOCR, Tesseract, or RapidOCR). Setting force_full_page_ocr=True ensures OCR runs on all images, even if the page contains other content. Using image_mode="placeholder" in export_to_markdown will output the extracted text from images instead of embedding the images as base64 [source] [source].
If you still don’t see text extracted from images, check that your images are not too small or low-contrast, and that your OCR engine supports the language in your images.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
ModuleNotFoundError Traceback (most recent call last) /tmp/ipython-input-4125604048.py in <cell line: 0>() 2 from docling.datamodel.pipeline_options import EasyOcrOptions, PipelineOptions 3 from docling.document_converter import DocumentConverter, FormatOption ----> 4 from docling.backends.powerpoint import MsPowerpointDocumentBackend 5 from docling.pipelines.simple_pipeline import SimplePipeline 6
ModuleNotFoundError: No module named 'docling.backends' help me with this error
The error is because the import path should be docling.backend.mspowerpoint_backend, not docling.backends.powerpoint reference. Here’s how to fix your code:
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import EasyOcrOptions, PipelineOptions
from docling.document_converter import DocumentConverter, FormatOption
from docling.backend.mspowerpoint_backend import MsPowerpointDocumentBackend
from docling.pipeline.simple_pipeline import SimplePipeline
ocr_options = EasyOcrOptions(force_full_page_ocr=True, do_ocr=True)
pipeline_options = PipelineOptions(ocr_options=ocr_options)
pptx_format_option = FormatOption(
pipeline_cls=SimplePipeline,
backend=MsPowerpointDocumentBackend,
pipeline_options=pipeline_options
)
converter = DocumentConverter(
format_options={InputFormat.PPTX: pptx_format_option}
)
result = converter.convert("22804.pptx")
print(result.document.export_to_markdown(image_mode="placeholder"))
OCR is enabled by default, but you can force it as shown above. Make sure you have an OCR engine installed (like EasyOCR, Tesseract, or RapidOCR). Use image_mode="placeholder" to output extracted text from images instead of base64 reference. Direct backend/pipeline customization is only needed for advanced OCR settings—normally, DocumentConverter auto-selects the correct backend for PPTX.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
ValidationError Traceback (most recent call last) /tmp/ipython-input-1134076218.py in <cell line: 0>() 5 from docling.pipeline.simple_pipeline import SimplePipeline 6 ----> 7 ocr_options = EasyOcrOptions(force_full_page_ocr=True, do_ocr=True) 8 pipeline_options = PipelineOptions(ocr_options=ocr_options) 9
/usr/local/lib/python3.11/dist-packages/pydantic/main.py in init(self, **data)
251 # __tracebackhide__ tells pytest and some other tools to omit this function from tracebacks
252 tracebackhide = True
--> 253 validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
254 if self is not validated_self:
255 warnings.warn(
ValidationError: 1 validation error for EasyOcrOptions do_ocr Extra inputs are not permitted [type=extra_forbidden, input_value=True, input_type=bool] For further information visit https://errors.pydantic.dev/2.11/v/extra_forbidden
help me solve this issue and also tell me what modules should i install for this codesnippet to work
The ValidationError happens because EasyOcrOptions does not accept a do_ocr argument—only valid fields like force_full_page_ocr are allowed. To enable OCR for extracting text from images in PPTX files, you should set do_ocr and force_full_page_ocr in the pipeline options, not in EasyOcrOptions itself.
Here’s a corrected code snippet:
from docling.datamodel.base_models import InputFormat
from docling.datamodel.pipeline_options import PipelineOptions
from docling.document_converter import DocumentConverter, FormatOption
from docling.backend.mspowerpoint_backend import MsPowerpointDocumentBackend
from docling.pipeline.simple_pipeline import SimplePipeline
# Set do_ocr and force_full_page_ocr in PipelineOptions
pipeline_options = PipelineOptions(
do_ocr=True,
force_full_page_ocr=True
)
pptx_format_option = FormatOption(
pipeline_cls=SimplePipeline,
backend=MsPowerpointDocumentBackend,
pipeline_options=pipeline_options
)
converter = DocumentConverter(
format_options={InputFormat.PPTX: pptx_format_option}
)
result = converter.convert("22804.pptx")
print(result.document.export_to_markdown(image_mode="placeholder"))
For this to work, you need to install docling and at least one OCR engine. For example, to use EasyOCR (the default):
pip install docling easyocr
Or, for Tesseract:
pip install docling tesserocr
(Tesseract also requires the Tesseract binary installed and available in your PATH.)
Or, for RapidOCR:
pip install docling rapidocr_onnxruntime
You can select the OCR engine and language in pipeline options if needed. To output extracted text from images in markdown, use image_mode="placeholder" as shown above. More details and troubleshooting tips are available in the Docling OCR setup guide.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
I have installed easy ocr and i have used the exact same code that you have provided but it is still not extracting text inside images and slides inside the ppt it is only able to extract the headings
Docling does not currently perform OCR on images in PPTX files by default—only native text (like headings and paragraphs) is extracted. The backend for PPTX adds images to the document but does not run OCR on them, which is why you only see headings and not text from images, even with OCR options enabled. To extract text from images in PPTX, you need to run an enrichment model that applies OCR to the images after the initial conversion. There’s an example of how to do this here: develop_picture_enrichment (discussion).
Alternatively, you can convert your PPTX to PDF and use Docling’s PDF pipeline, which does support OCR on images, but this may affect table detection and formatting.
If you want to debug what’s happening, you can enable OCR visualization with:
from docling.datamodel.settings import settings
settings.debug.visualize_ocr = True
Let me know if you want a code snippet for the enrichment model approach or help interpreting debug output.
To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.
you have suggested two methods right so tell me the ideal way to do it and also give me the code step by step and tell me what i have to install and what i have to run be very clear
The ideal way to extract text from images in PPTX files with Docling is to use the enrichment model workflow. This is a two-step process: first, convert your PPTX to a DoclingDocument; then, run an enrichment step that applies OCR to the images inside the document. This approach preserves document structure and is the recommended method for robust results (reference, reference).
Step 1: Install requirements
- Python 3.9–3.13
- Docling and an OCR engine (EasyOCR is the default and easiest to set up):
pip install docling easyocr
Step 2: Convert PPTX to DoclingDocument
from docling.document_converter import DocumentConverter
result = DocumentConverter().convert("yourfile.pptx")
doc = result.document
doc.save_to_json("yourfile.docling.json")
Step 3: Run enrichment (OCR) on images in the document
from docling.datamodel.document import DoclingDocument
from docling.models.document_picture_classifier import DocumentPictureClassifier, DocumentPictureClassifierOptions
from docling.datamodel.accelerator_options import AcceleratorOptions
# Load the DoclingDocument
doc = DoclingDocument.load_from_json("yourfile.docling.json")
# Initialize the enrichment model (OCR/classifier)
model = DocumentPictureClassifier(
enabled=True,
artifacts_path=None,
options=DocumentPictureClassifierOptions(),
accelerator_options=AcceleratorOptions(),
)
# Run enrichment on all images (PictureItem nodes)
for pic in doc.pictures:
for enriched in model(doc, [pic]):
pass # The model will annotate pic.annotations with OCR/classification results
# Export to markdown with extracted text from images
print(doc.export_to_markdown(image_mode="placeholder"))
What to expect:
This will output the extracted text from images in your PPTX, along with the regular text content. The enrichment model will annotate each image with OCR results, which are included in the markdown output when you use image_mode="placeholder".
Caveats:
- This workflow is robust and preserves document structure.
- If you want a simpler but less robust method, you can convert PPTX to PDF (using LibreOffice CLI or similar), then run Docling's PDF pipeline with enrichment enabled, but you may lose some formatting or table detection (reference).
- You can customize the enrichment step to use different OCR or vision models if needed.
For more advanced enrichment (like image captioning or using remote vision models), see the enrichment documentation and example scripts.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
Classification labels added: pptx.
These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.