microsoft / microsoft/markitdown
[bug] Markitdown failed to convert pdf that contains image
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 186k
- Forks
- 13.7k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 49
Description
cn_dissertation_1st_page.pdf
In trying to analyze the attached file with
result = md.convert(file_path)
return result.text_content
I got the following error
Traceback (most recent call last):
File "/Users/fengjunchen/Library/Caches/pypoetry/virtualenvs/ai-advisor-IuYXIAy1-py3.10/lib/python3.10/site-packages/markitdown/_markitdown.py", line 1239, in _convert
res = converter.convert(local_path, **_kwargs)
File "/Users/fengjunchen/Library/Caches/pypoetry/virtualenvs/ai-advisor-IuYXIAy1-py3.10/lib/python3.10/site-packages/markitdown/_markitdown.py", line 490, in convert
text_content=pdfminer.high_level.extract_text(local_path),
File "/Users/fengjunchen/Library/Caches/pypoetry/virtualenvs/ai-advisor-IuYXIAy1-py3.10/lib/python3.10/site-packages/pdfminer/high_level.py", line 169, in extract_text
for page in PDFPage.get_pages(
File "/Users/fengjunchen/Library/Caches/pypoetry/virtualenvs/ai-advisor-IuYXIAy1-py3.10/lib/python3.10/site-packages/pdfminer/pdfpage.py", line 171, in get_pages
for (pageno, page) in enumerate(cls.create_pages(doc)):
File "/Users/fengjunchen/Library/Caches/pypoetry/virtualenvs/ai-advisor-IuYXIAy1-py3.10/lib/python3.10/site-packages/pdfminer/pdfpage.py", line 127, in create_pages
yield cls(document, objid, tree, next(page_labels))
File "/Users/fengjunchen/Library/Caches/pypoetry/virtualenvs/ai-advisor-IuYXIAy1-py3.10/lib/python3.10/site-packages/pdfminer/pdfpage.py", line 64, in __init__
resolve1(mediabox_param) for mediabox_param in self.attrs["MediaBox"]
KeyError: 'MediaBox'
I am running it on Python 3.10 in MacOS 15.2 (24C101)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with cn_dissertation_1st_page.pdf using the shown md.convert(file_path) call. Start in markitdown/_markitdown.py at the PDF converter and inspect the pdfminer.high_level.extract_text call that raises KeyError: 'MediaBox'. Done means the attached PDF converts successfully and returns text_content without the exception.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100