#1942·xberg

feat(renderer): render extraction output as DOCX

Author: GoldziherCreated Sep 28, 2026Updated Sep 29, 2026
LabelsenhancementP2

Context

Requested alongside external-findings redaction: return the (redacted) document as .docx.

Current state

  • OutputFormat has no Docx variant (Plain / Markdown / Djot / Html / DocTags / Custom).
  • xberg reads DOCX (extractor) but never emits one.
  • Custom Renderer plugins are supported via OutputFormat::Custom(name), but the Renderer trait returns Result<String>, which cannot carry binary OOXML without an encoding convention.

Scope — two distinct features

  1. Render extracted content to a fresh DOCX. Build a new document from the element tree. Feasible with a crate like docx-rs; layout fidelity limited to what the element tree retains.
  2. In-place destructive redaction of the original DOCX. Rewrite the original OOXML runs/parts so surrounding layout, styles and non-text content are preserved. This is what "redact the PCI in the docx file" actually requires, and is much larger: map redactions back onto w:r/w:t runs and handle headers/footers/notes/embedded parts. The PDF side already has an analogous destructive path (xberg-native-pdf::redact_content_stream).

Proposal

  • Add OutputFormat::Docx + built-in renderer for (1).
  • Decide whether (2) is in scope; if yes, file it separately.
  • Resolve the binary-renderer gap: allow renderers to emit bytes, or document a base64 convention.

Acceptance criteria

  • --content-format docx emits a valid .docx that opens in Word/LibreOffice.
  • Round-trip: extracted text of the emitted DOCX matches the source content.
  • Redaction findings are absent from the emitted DOCX.