OCR plugin for MarkItDown - Extracts text from images in PDF, DOCX, PPTX, and XLSX via LLM Vision
Actively maintained. Last release 6 weeks ago, commits in 11 of the last 26 weeks. A safe choice.
pip install markitdown-ocrMarkItDown OCR Plugin
LLM Vision plugin for MarkItDown that extracts text from images embedded in PDF, DOCX, PPTX, and XLSX files.
Uses the same llm_client / llm_model pattern that MarkItDown already supports for image descriptions — no new ML libraries or binary dependencies required.
Features
- Enhanced PDF Converter: Extracts text from images within PDFs, with full-page OCR fallback for scanned documents
- Enhanced DOCX Converter: OCR for images in Word documents
- Enhanced PPTX Converter: OCR for images in PowerPoint presentations
- Enhanced XLSX Converter: OCR for images in Excel spreadsheets
- Context Preservation: Maintains document structure and flow when inserting extracted text
Installation
Requires markitdown>=0.1.8,<0.2.0, which provides the Office image-rendering hooks used by this plugin. Installing the plugin automatically resolves a compatible core version.
pip install markitdown-ocr
The plugin uses whatever OpenAI-compatible client you already have. Install one if you don't have it yet:
pip install openai
Usage
Command Line
markitdown document.pdf --use-plugins --llm-client openai --llm-model gpt-4o
Python API
Pass llm_client and llm_model to MarkItDown() exactly as you would for image descriptions:
from markitdown import MarkItDown
from openai import OpenAI
md = MarkItDown(
enable_plugins=True,
llm_client=OpenAI(),
llm_model="gpt-4o",
)
result = md.convert("document_with_images.pdf")
print(result.text_content)
If no llm_client is provided the plugin still loads, but OCR is silently skipped — falling back to the standard built-in converter.
Custom Prompt
Override the default extraction prompt for specialized documents:
md = MarkItDown(
enable_plugins=True,
llm_client=OpenAI(),
llm_model="gpt-4o",
llm_prompt="Extract all text from this image, preserving table structure.",
)
Any OpenAI-Compatible Client
Works with any client that follows the OpenAI API:
from openai import AzureOpenAI
md = MarkItDown(
enable_plugins=True,
llm_client=AzureOpenAI(
api_key="...",
azure_endpoint="https://your-resource.openai.azure.com/",
api_version="2024-02-01",
),
llm_model="gpt-4o",
)