jrjsmrtn/structured-data-skills/extract-document-text
Claude Code and agent skill by jrjsmrtn/structured-data-skills
- community
Checking that the SKILL.md file is still in the repository.
Extract text from PDFs, office documents and images, including scanned PDFs that need OCR. Use when a PDF returns no text, when reading a specification or datasheet programmatically, or when a document must be searched, quoted or checked rather than only viewed.
Install
npx vskill@latest install jrjsmrtn/structured-data-skills/extract-document-textSKILL.md
The same SKILL.md was published earlier as jrjsmrtn/structured-data-skills/extract-document-text.
Extract Document Text
Get text out of documents so it can be searched, quoted and verified — not merely displayed.
When to Use
- A PDF must be read programmatically: a specification, standard, datasheet, enacting text
pdftotextreturned nothing, or returned layout garbage- A document is a scan — an image wrapped in a PDF — and needs OCR
- Extracting from office formats, HTML or images
Reach for one tool, not a decision tree
**xberg** (renamed from kreuzberg, same author) handles ~100 formats and falls through to OCR automatically when a PDF has no text layer. Prefer it as the default:
- It does not fail silently. A PDF with no text layer gets OCR'd rather than returning nothing.
- The native path is not slow. Measured at 0.1s on a text-layer PDF — the same as
pdftotext. Only the OCR path costs seconds.
- One call covers DOCX, HTML, images, not just PDF.
- Cleaner boundaries — no form-feed page furniture, which matters when chunking.
pdftotext remains worth knowing as the zero-dependency fallback: it is everywhere, needs no Python, and is correct whenever a text layer exists.
If you use it, check the word count and never the exit status. On a scanned PDF it exits 0 and produces an empty file — which reads as "empty document" rather than "wrong tool".
How far this was measured: two documents — one text-layer, one scan. Enough to prefer adefault; not enough to claim it generally. Re-measure on your own corpus if the choice matters.
Two distributions, and they share no interface
xberg ships as a Python package and as `xberg-cli`, a Rust binary — one project, one version line (both 1.0.14 as of 2026-08-20), two entirely different calling conventions. Neither is the real one. Pick by where you are calling from, and know which you installed: every note below is specific to one of them.
| Python package | xberg-cli | ||
|---|---|---|---|
| Get it | uv tool install xberg, pip install xberg | prebuilt binary from docs.xberg.io; also published on crates.io | |
| Interface | async Python API | subcommands, text or JSON on stdout | |
| Reach for it | you are already inside Python | a shell pipeline, a hook, a check, an agent |
The prebuilt binary is self-contained: it ships libheif, libaom, libx265 and libvmaf alongside it, so HEIC and AV1 inputs work with no system codecs — and it is ~90 MB for that reason.
Using the CLI
`--stdin` without `-m` emits the raw file bytes and exits 0. Piping a PDF in with no MIME hintreturns the file itself —%PDF-1.3, a binary run,3 0 obj,/Filter /FlateDecode,stream—the container rather than the document, reported as a success. Detection works from a path and notfrom a pipe, so on the--stdinpath the hint is load-bearing. Same shape aspdftotextexiting 0on a scan: the failure arrives as content, not as an error.
--format json returns {"result": {…}, "extraction_time_ms": N}, so the text is at `.result.content` — and the fields you need in order to trust it sit right beside it:
result carries content, mime_type, metadata, extraction_method, tables, counts and quality_score.
OCR is flags, not a separate mode — and the flag worth knowing is not --ocr:
--ocr true|false, with--ocr-backend tesseract|paddle-ocr|vlm|candle-*--force-ocr true— OCR even where text extraction succeeded- `--ocr-scanned-pages` — OCR only the pages that look like scans, keeping native text
elsewhere. The one to reach for on a mixed document, and it catches the nastiest case: a scanned page carrying a junk hidden text layer that would otherwise pass the quality check and return garbage as if it were native text
--scanned-min-confidencedefaults to 0.7. Its help records that **0.50 or lower also OCRs
born-digital slides using a full-bleed background image** — a false positive you opt into, not one you discover
batch, chunk, embed and cache exist too, and `serve`/`mcp` expose extraction as an HTTP or MCP server — a third integration route, and the one to consider before writing a wrapper.
Measured — macOS,xberg-cli1.0.14, 2026-08-20, one text-layer PDF:xberg extractandpdftotextreturned the same 101 words, in 0.034 s and 0.039 s wall clock; self-reportedextraction_time_mswas 11.8. That is enough to say the native path costs nothing next topdftotext. It says nothing about the OCR path, and nothing about a corpus.
Using the Python package
Three things about that call, each of which costs an hour if guessed:
- it is async —
awaitit, or you measure a coroutine object and conclude the tool is broken - input is an `ExtractInput`, not a path string;
kind="uri"accepts a local path - text is at `output.results[0].content` — the return value is a container;
output.singleis a
method, so output.single is not None is always true and tells you nothing
What to check, whichever one you used
Always check `extraction_method` — output.results[0].extraction_method in Python, .result.extraction_method in the CLI's JSON. It reports native for a text layer and ocr when the page was recognised, and that distinction changes how far you can trust the text.
Structure recovery is document-dependent, not automatic. OCR performs layout analysis and can emit Markdown tables; the native path passes through whatever the PDF already contains. Measured: a scan produced Markdown tables, a text-layer policy document produced none. Do not assume you will get structure back.
OCR needs an engine installed — Tesseract is the common default. Expect seconds per document on that path only.
OCR text is not quotable without verification. Recognition silently substitutes characters, anda wrong character inside quotation marks is worse than no quote at all — it is citable and looksauthoritative. Before quoting any passage whereextraction_method == "ocr", check it against therendered page.
Read the documentation before introspecting
The three notes above are all stated on the project's own quickstart page. They were instead rediscovered by dir()-ing Rust-backed objects across four failed attempts, each producing a plausible "0 characters" that looked like a broken tool and was a broken measurement.
Before writing a line against an unfamiliar library: find its quickstart, and check whether it ships an assistant plugin or conventions file. Many now do, and that is the cheapest possible source of the calling convention.
Fetching what you are about to extract
When the document is behind a URL, the cost of getting this wrong is a plausible non-document — see the next section. Escalate deliberately; each rung is heavier and less reproducible than the one above it.
- A published machine-readable form, if there is one.
llms.txt,llms-full.txt, a single-page
print.html, the .md beside an HTML page — or, for a document with a canonical format, that format: an RFC's .xml, a standard's source rather than its rendering. Cheapest, most faithful, and it beats every rung below when it exists. See process-structured-data, A rendered document is not the document. llms.txt is a proposal — Answer.AI, September 2024 — and not a standard: no standards body has adopted it, whatever a search result tells you. Adoption across tool and framework docs is still wide enough to be worth one request first.
- `curl`. The default whenever the target is already a document — a PDF, a spec, a raw file.
Milliseconds, no dependencies, byte-exact.
- `xberg extract --url` when you want the text rather than the bytes: it fetches and extracts
in one step, and reports extraction_method for what it did.
- A real browser — Playwright. Only when the content does not exist until JavaScript has run,
when a challenge page or cookie wall stands in front of it, or when reaching it needs interaction or a session.
Escalate on evidence, not on annoyance. A 200 carrying a challenge page, an SPA shell or a cookie wall is the signal to go up a rung. A 200 carrying the document in a layout you dislike is not — that is an extraction problem, and rung 4 will not fix it.
Rung 4 produces a different kind of evidence. A browser renders; what you captured is whatthat browser build produced on that date, and a later run may differ. When a claim rests onrendered behaviour rather than on a file's bytes, **record the browser and its version beside thedate**. "Observed via Playwright, browser version not recorded" is a limit you will have to statein the record later; recording it costs one line now.
Verifying an extraction
An extraction that returns something is not an extraction that returned the document.
- Check the content, never the status code. A
200or an exit0proves the tool ran. Grep the
output for text you know is in the document — a heading, a section number, a phrase.
- Beware plausible non-documents. Landing pages, SPA shells, cookie walls and proof-of-work
challenge pages are large, well-formed, and contain none of what you asked for.
- A challenge page also destroys the existence signal. Hosts running proof-of-work interstitials
return the same 200 for any path, including ones that do not exist — so "blocked" and "the URL is wrong" are indistinguishable. Confirm a URL from a page that actually resolves before recording a source as unreachable.
- Prove absence rather than truncation. If a passage seems missing, check for the sections that
bracket it. Neighbours present and passage absent means genuinely absent; neighbours missing too means a partial fetch.
Quoting from an extracted document
- Count, do not skim. To claim a term does not appear, count occurrences programmatically. *"I did
not see it"* is not a finding.
- One source, two formats, two answers. A specification published as both HTML and PDF can
disagree. Where both exist, the comparison is the verification — and where nothing settles which governs, record the disagreement rather than picking one silently.
- Date what you checked. Extracted text is a snapshot; the document is not.
Related Skills
process-structured-data— once text is out, querying and editing it without corrupting the file
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/extract-document-text/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jrjsmrtn/structured-data-skills/extract-document-text)