Skip to content

fix: recover PDF text after inline images#1889

Open
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/pdf-inline-image-recovery
Open

fix: recover PDF text after inline images#1889
he-yufeng wants to merge 1 commit into
microsoft:mainfrom
he-yufeng:fix/pdf-inline-image-recovery

Conversation

@he-yufeng

Copy link
Copy Markdown

Summary

  • add a lazy PyMuPDF text-recovery pass for PDFs with inline image operators
  • keep PyMuPDF optional: no default dependency change, and the fallback only runs when the package is installed
  • warn instead of silently returning likely partial text when inline-image recovery is needed but PyMuPDF is unavailable
  • add regression coverage for both the recovery and warning paths

Addresses #1870.

Test plan

  • python -m pytest packages/markitdown/tests/test_pdf_memory.py -q -k "inline_image"
  • python -m pytest packages/markitdown/tests/test_pdf_memory.py packages/markitdown/tests/test_pdf_tables.py -q
  • python -m py_compile packages/markitdown/src/markitdown/converters/_pdf_converter.py packages/markitdown/tests/test_pdf_memory.py
  • python -m mypy --ignore-missing-imports packages/markitdown/src/markitdown/converters/_pdf_converter.py packages/markitdown/tests/test_pdf_memory.py
  • python -m pip install -e "packages/markitdown[pymupdf]"
  • git diff --check

@he-yufeng

Copy link
Copy Markdown
Author

Rebased onto current main; no conflicts.

Focused validation after the rebase:

python -m py_compile packages\markitdown\src\markitdown\converters\_pdf_converter.py packages\markitdown\tests\test_pdf_memory.py
$env:PYTHONPATH='C:\dev\GITHUB-clean\markitdown-1889\packages\markitdown\src'; python -m pytest packages\markitdown\tests\test_pdf_memory.py -q
git diff --check origin/main..HEAD

Result: 8 passed, 2 skipped for the focused PDF memory tests.

@he-yufeng he-yufeng force-pushed the fix/pdf-inline-image-recovery branch from b75be1c to 678aa48 Compare June 12, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants