text-extract/MODULE.md
flemming-it fdb5deaa8b
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Failing after 2s
docs: add MODULE.md + MODULE.de.md inline docs
Studio reads MODULE.md / MODULE.<locale>.md from the installed
bundle and renders it in the module-detail Documentation
section. text-extract ships them now — EN+DE peers, same
schema as the README but trimmed for the in-app reader.

Signed-off-by: flemming-it <sf@flemming.it>
2026-05-25 14:06:04 +02:00

2.5 KiB

text.extract

Plain-text extraction from PDF and DOCX documents. Pure-Rust, in-WASM, no permissions required. The canonical first step in any flow that needs raw text — anonymise, summarise, translate, LLM-classify, audit-redact.

Capability

  • text.extract@0.1.0

Inputs

Name Type Description
document bytes The document to extract. Accepted MIME types below.

Accepted MIME types (declared in module.yaml#accepts_mime, read by Studio as the file-picker filter):

  • application/pdf
  • application/x-pdf
  • application/vnd.openxmlformats-officedocument.wordprocessingml.document

Other MIME types are rejected with a invalid_input error before any parsing happens.

Output

Name Type Description
extracted json ExtractedDocument schema below.
{
  "engine": "pdf-extract",
  "engine_version": "0.7",
  "pages": [
    { "number": 1, "text": "…" }
  ]
}

Per-page confidence and bbox fields are reserved in the schema for a future service-mode variant (pdfium / mupdf via host services) that surfaces layout information. v0.1.0 does not populate them; the schema accepts them as optional.

Permissions

None. Pure-Rust pipeline (pdf-extract, zip, quick-xml). No filesystem, no network. The empty permissions: [] in module.yaml makes that explicit; the hub enforces it.

Limits in v0.1.0

  • Layout-naive PDF. Multi-column or table-heavy documents may produce reordered text. Single-column body text is solid.
  • No OCR. Scanned (image-only) PDFs return empty text per page. Pair with a future text.ocr@^0 step for those.
  • DOCX-only Office. .doc (legacy binary), .rtf, .odt are not yet supported.

Bumping to 1.0.0 requires either the service-mode variant (pdfium-quality output + layout) or a confirmed-good extraction score on a representative corpus.

Example flow

name: extract-anonymise
inputs:
  document: bytes
steps:
  - id: extract
    use: text.extract@^0
    with:
      document: $inputs.document
  - id: redact
    use: text.anonymize@^0
    with:
      text: $extract.extracted.pages[*].text
outputs:
  redacted: $redact.anonymized

Build

cargo build --release --target wasm32-wasip2
# Output: target/wasm32-wasip2/release/text_extract.wasm