markitdown icon indicating copy to clipboard operation
markitdown copied to clipboard

PDF Parsing Issues: Incorrect Formula Recognition & Strange (cid:XXX) Symbols

Open nuocheng opened this issue 5 months ago • 1 comments

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:

  1. Mathematical/Chemical formula recognition errors The formulas in the PDF are not recognized correctly; the converted result has wrong symbols and structure.

  2. Unexpected strange symbols appear: (cid:7220), (cid:3742) Many meaningless tokens like (cid:XXX) show up in the output text, which should not exist.

Image Image

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)

nuocheng avatar Jun 07 '26 00:06 nuocheng

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.

Jakeshadow avatar Jun 08 '26 06:06 Jakeshadow