Cookbook
Runnable recipes for PDF to Markdown, chunking, RAG and document processing with PyMuPDF. Open any recipe in Colab or download the notebook.
Fuzzy Number Matching with the PyMuPDF Grounding Skill
Match numbers in AI quotes against their word equivalents in a PDF
Chunked Documents with PyMuPDF
Chunk blocks of text with bounding boxes using PyMuPDF.
Build an Evidence Pack for an AI Answer
Turn an AI answer and its citations into one PDF that a reviewer, an auditor or a customer can check without any other tools.
Catch Hallucinated Citations
Run every quote an AI answer cites through the source PDF, and count the ones that are not there.
Cite the Table Cell, Not the Page
When an AI answer quotes a number from a financial table, point to the exact cell, with its row and column, instead of the whole page.
Know Which Evidence Came from OCR
Not all text in a PDF is equally reliable. Tell born-digital text from OCR text, and flag OCR evidence for review.
Verify AI-Extracted Values Against the PDF
An LLM pulls fields out of an invoice or contract. Before anyone relies on them, check each value against the document and show where it is printed.
Keep Page Coordinates with Your RAG Chunks
Every chunk in your vector store can remember exactly where it came from in the PDF. PyMuPDF already gives you the coordinates; this article shows how to keep them.
Cite Claude Answers
Sends a PDF to Claude with citations enabled, locates each cited passage on the page with PyMuPDF, highlights it, and exports coordinates for a web viewer.
Ask a PDF and Highlight the Evidence
Answer questions from a PDF with page citations, verify each quoted passage, and create a copy with the evidence highlighted using PyMuPDF.
Convert an email to a PDF
Turn an email into a PDF document using PyMuPDF.
Convert a PDF to Markdown for RAG
Turn a PDF into structured Markdown and token-sized chunks ready for embedding, using PyMuPDF locally with no GPU or API key.
PDF Highlighting with Citations
Use Claude to analyze a PDF and highlight the passages that support its answers.