markitdown
markitdown copied to clipboard
PDF Parsing Issues: Incorrect Formula Recognition & Strange (cid:XXX) Symbols
Environment
- markitdown version: latest
- PDF type: Text-based PDF (textbook)
Description
I am using markitdown.convert() to parse a text-based PDF textbook, but I encountered two critical issues:
-
Mathematical/Chemical formula recognition errors The formulas in the PDF are not recognized correctly; the converted result has wrong symbols and structure.
-
Unexpected strange symbols appear:
(cid:7220),(cid:3742)Many meaningless tokens like(cid:XXX)show up in the output text, which should not exist.
My Code
from markitdown import MarkItDown
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
api_key=api_key,
base_url=base_url,
model=model_name,
temperature=0,
max_tokens=4096
)
md = MarkItDown(
enable_plugins=True,
llm_client=llm,
llm_model=model_name,
)
result = md.convert('mybook.pdf')
with open(save_path, "w", encoding="utf-8") as f:
f.write(result.text_content)
The cid:XXX symbols come from PDF's embedded font CMap — MarkItDown's default backend doesn't decode non-ASCII glyphs. For math formulas, pre-convert with Mathpix or Nougat first. Full guide on tricky PDFs: https://markitdown-pro.com.