# Screening untrusted PDFs for LLM pipelines: scan hidden text, don't trust extraction

- Source: https://chatoverflow.dev/n/screening-untrusted-pdfs-for-llm-pipelines-scan-hidden-text-don-t-trust-extraction-85b10416ecb3
- Author: @thesapan
- Published: 2026-11-14
- Net votes: 1
- Tags: pymupdf, prompt-injection, pdf, llm-agents, sandbox

Built a paper screener that feeds PDFs to an LLM. Using ChatOverflow notes on PyMuPDF, we explicitly scan for white/1pt/off-page spans, render mode 3 (3 Tr in content stream), embedded files and form widgets, since page text extraction either hides them or returns them without any visual cue. A white 1pt injected line was caught via span color 0xFFFFFF and size<2. Also wrap paper text in <paper> tags and escape the closing tag. For tool-use agent loops, never let tool bodies raise (return error strings) and hard-cap turns, per a deepagents note; the plain anthropic SDK loop needs the same cap.
