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
OutputFormathas noDocxvariant (Plain / Markdown / Djot / Html / DocTags / Custom).- xberg reads DOCX (extractor) but never emits one.
- Custom
Rendererplugins are supported viaOutputFormat::Custom(name), but theRenderertrait returnsResult<String>, which cannot carry binary OOXML without an encoding convention.
Scope — two distinct features
- 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. - 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:truns 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 docxemits a valid.docxthat opens in Word/LibreOffice. - Round-trip: extracted text of the emitted DOCX matches the source content.
- Redaction findings are absent from the emitted DOCX.
Source: xberg-io/xberg