Add a plugin-first PaddleOCR package for scanned PDF fallback#1652
Draft
jimmyzhuu wants to merge 1 commit intomicrosoft:mainfrom
Draft
Add a plugin-first PaddleOCR package for scanned PDF fallback#1652jimmyzhuu wants to merge 1 commit intomicrosoft:mainfrom
jimmyzhuu wants to merge 1 commit intomicrosoft:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This draft PR proposes a new package,
markitdown-paddleocr, as a plugin-first OCR option for scanned PDFs.The scope is intentionally narrow:
This is presented as a draft because my main goal is to make the implementation and tradeoffs easy to review before assuming this package belongs in the main repository.
Why this package exists
MarkItDown already has two strong paths today:
This package is aimed at a different use case that is not fully covered by those two paths:
In local testing with representative Chinese samples, the current built-in MarkItDown flow returned empty output for scanned pages, while a PaddleOCR-based fallback recovered meaningful text. The strongest results were on report-style and table-heavy pages.
Design goals
The implementation is deliberately conservative.
It does not try to replace the built-in PDF converter, and it does not try to replace the existing
markitdown-ocrpackage.Instead, it uses the following strategy:
PdfConverterfirstThis means:
Why plugin-first
This package follows the plugin-first direction already present in MarkItDown:
That is also why this package does not introduce new core constructor arguments or provider-specific CLI flags in MarkItDown itself.
Why PaddleOCR specifically
The motivation here is not provider branding. The motivation is that PaddleOCR fills a practical gap in the current extension landscape:
That made it a reasonable candidate for a plugin package that complements, rather than replaces, the existing LLM-based OCR path.
What is included in this PR
This PR adds a new package under
packages/markitdown-paddleocrwith:pyproject.tomlplugin package definitionPaddleOCRServicewith lazy backend initializationPdfConverterWithPaddleOCRthat only falls back when the built-in PDF result is emptyWhat is explicitly out of scope
This PR does not attempt to do any of the following:
markitdown-ocrImplementation notes
Fallback behavior
The main converter is intentionally narrow and easy to reason about:
Dependency boundary
The package keeps Paddle-specific dependencies isolated to the plugin package rather than expanding the dependencies of
packages/markitdown.Configuration model
The plugin reads opt-in kwargs during plugin registration:
paddleocr_enabledpaddleocr_langpaddleocr_kwargsThese stay inside the plugin path and do not require MarkItDown core API changes.
Local demo observations
Local demo notes are included in
packages/markitdown-paddleocr/DEMO.md.In the local samples used during testing:
This does not prove that the package solves every OCR scenario. It does suggest that it covers a real gap with a narrow plugin-first design.
Tests
This package currently includes unit tests that verify:
Why open this as a draft
I wanted to surface the full implementation for review while still signaling that I am open to feedback on repository fit.
If maintainers feel that:
I am happy to adjust the scope.
Backward compatibility
This PR does not change the behavior of the default MarkItDown installation.
Users only get this functionality if they install the plugin package and opt in to it.
Related context