How do you convert PDFs to RAG-ready data?

To convert PDFs to RAG-ready data, extract the text into clean, structured Markdown using a document parser, then split it into chunks for embedding in a vector store. The extraction step is the hardest part, because rule-based parsers work for machine-generated PDFs with consistent layouts but fail on scanned documents, complex tables, or PDFs where multi-column layouts produce garbled reading order.

FactorPyMuPDF / pdfplumberLLM-based extractionFirecrawl document parsing
Scanned PDF supportNoYesYes (auto or OCR mode)
Table structurePartialSemantically understoodPreserved in Markdown
Reading orderCan garble multi-columnCorrectCorrect
Output formatRaw text stringsSchema-defined JSONStructured Markdown
SetupLocal installAPI + prompt engineeringSingle API call

Use rule-based parsers for structured, machine-generated PDFs where extraction is deterministic. For mixed corpora (research papers, filings, contracts, reports) where formats vary, LLM-based extraction or a managed parsing API produces more consistent chunks.

For web-hosted PDFs, Firecrawl /scrape with document parsing converts them to clean Markdown in one API call. For local or non-public documents, upload them to Firecrawl /parse to get the same Markdown output. Headings, tables, and lists come through in a form that chunking libraries like LangChain's RecursiveCharacterTextSplitter can split directly. Set pages on the PDF parser to get one Markdown string per page, so every chunk keeps the page number it came from:

from firecrawl import Firecrawl
from langchain_text_splitters import RecursiveCharacterTextSplitter
 
firecrawl = Firecrawl(api_key="fc-YOUR-API-KEY")
 
doc = firecrawl.scrape(
    "https://arxiv.org/pdf/1706.03762",
    formats=["markdown"],
    parsers=[{"type": "pdf", "pages": True, "max_pages": 3}],
)
 
splitter = RecursiveCharacterTextSplitter(chunk_size=1000, chunk_overlap=100)
chunks = [
    {"page": page.page_number, "text": text}
    for page in doc.pages
    for text in splitter.split_text(page.markdown)
]
 
print(len(chunks), chunks[0]["page"], chunks[-1]["page"])

On Oct 30, 2026 this turned the first 3 pages of the Transformer paper into 14 chunks tagged with pages 1 to 3, for 3 Firecrawl credits. PDF parsing costs 1 Firecrawl credit per page, and the pages and pageMarkers options add nothing. If your pipeline only takes one Markdown string, pageMarkers writes an HTML comment at each page break instead. For scanned sources, set mode to ocr on the PDF parser to force OCR on every page before chunking.

Fire-PDF is Firecrawl's Rust-based PDF engine. It sends text-based pages to native extraction and only scanned pages through the GPU, averaging under 400ms per page on mixed documents. The PDF parser v2 release explains the three parsing modes. For a hands-on comparison of PDF parsers for RAG, including Docling, Marker-PDF, LlamaParse, and Reducto alongside Firecrawl, see the dedicated PDF parser guide. For a wider evaluation of document parsing APIs, see the best document parsing APIs guide.

Last updated: Oct 30, 2026
//
Get started
//
Ready to build?
Start getting web context for free and scale seamlessly as your project expands. No credit card needed.
Are you an AI agent? See setup options