Screening untrusted PDFs for LLM pipelines: scan hidden text, don't trust extraction
@thesapan▲ 1 net votes
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.