Why PDF is difficult
PDF describes where glyphs and graphics appear on a page. It may not encode the semantic order a reader sees. Multi-column layout, repeated furniture, split tables, ligatures, and embedded images all complicate a linear text view.
A parser must infer structure from coordinates, fonts, rules, and sometimes pixels. The result should state which path was used, because confidence in a deterministic text layer is different from confidence in OCR over a low-resolution scan.
What good Markdown looks like
Headings should form a coherent hierarchy. Lists should remain grouped. Tables need headers and row alignment. Page separators should not interrupt every sentence, but page metadata must remain available for citation. Repeated headers and footers should be removed only when the pattern is reliable.
Do not optimize solely for visual resemblance. The Markdown is an intermediate representation for chunking and models; it should be semantically clear, compact, and stable.
- Use headings as primary chunk boundaries.
- Keep captions with their figure or table context.
- Retain code fences and formula notation where supported.
- Store page and block IDs outside the plain Markdown string.
Chunk after normalization
Apply a structure-aware pass first, then enforce model token limits. A section may contain several paragraphs that belong together; a long table may require its own row-group strategy. Fixed windows should be the fallback, not the source of truth.
Attach heading path, page range, content hash, and parser version to every chunk. When content is updated or reprocessed, replace the affected index version atomically.
Test the actual LLM task
Visually inspect samples, but also ask questions whose answers depend on reading order, a table cell, a footnote, and cross-page context. Record whether the failure came from conversion, chunking, retrieval, or generation.
The right PDF-to-Markdown implementation is the one that improves the target task within acceptable latency, cost, and operational limits—not the one with the longest feature list.
Frequently asked questions
Questions teams ask before building
Is Markdown the best format for every LLM document?
Markdown is a strong readable interchange format, but applications should keep structured metadata for pages, blocks, tables, provenance, and citations.
Should page breaks appear in Markdown?
Only when useful to the consumer. Preserve page identifiers in structured metadata even if the readable Markdown minimizes page separators.
Can OCR errors be fixed during chunking?
Chunking can remove noise but cannot reliably reconstruct missing or misrecognized text. Improve or reroute parsing before indexing.