Turn PDFs into LLM-Ready Markdown with Docling (2026) — layout-aware PDF conversion that feeds RAG and chat pipelines without brittle regex scrapes.
If you already route models with LiteLLM or extract structures with Instructor, Docling is the ingest step: DocumentConverter → Markdown your LLM can actually use.
TL;DR
pip install doclingthenDocumentConverter().convert(source)- Export with
result.document.export_to_markdown()orsave_as_markdown(...) - Works with local paths or URLs; auto-detects PDF/DOCX/HTML and more
- Enable OCR / table structure for scans when needed
Install
pip install docling
# or: uv add docling
Example 1 — PDF URL to Markdown
from docling.document_converter import DocumentConverter
source = "https://arxiv.org/pdf/2408.09869" # Docling paper
converter = DocumentConverter()
result = converter.convert(source)
md = result.document.export_to_markdown()
print(md[:500])
print("status:", result.status)
Example 2 — local file + save
from pathlib import Path
from docling.document_converter import DocumentConverter
converter = DocumentConverter()
result = converter.convert(Path("reports/q3.pdf"))
result.document.save_as_markdown("reports/q3.md")
For scanned pages, configure PDF pipeline options (do_ocr=True, table structure) so headings and tables survive into Markdown.
Trace the downstream LLM calls with Langfuse once chunks hit your app.
Production tips
- Check
result.statusbefore indexing failed conversions - Chunk Markdown by headings for RAG — do not dump entire books into one prompt
- Cache converted
.mdbeside the PDF; reconvert only on change - Prefer Docling over naive
pdftotextwhen layout (tables, columns) matters
Wrap-up
In 2026, RAG quality starts at ingest. Docling turns messy PDFs into structured Markdown so your LLM stack spends tokens on answers — not on fighting layout.