gemini 2.5-flash consistently fails badly on PDFs

Basically, I'm trying to call Gemini through API and use it for OCRing (in my opinion) not so complex PDFs, and get nice clean markdown. They are fully digital PDFs, not scanned. If it's just text, it works perfectly. However, when there's a table, it very often starts writing the table in markdown, and almost immediately gets stuck in the loop of infinite ————————————————————————————————————- spam, rendering the returned markdown practically useless.

The model I tried so far is just gemini 2.5-flash.

Does anyone has some experience with this, and can help? Any settings, prompts that could help me save the issue?

I need the markdown for future LLM processing. I also need some kind of catch-all model/program to return the markdown from PDF. Classical methods are either good for just tables, or just free text outside tables, and combining them is hell. Gemini is my last, and so far best resort, but still not quite there.

Leave a Reply