Control DOCX export
Download an edited DOCX, return its bytes, or package related files.
Export the document you have edited, then choose what your application does with the file. The browser Editor exports DOCX; it does not convert the document to PDF or HTML through this method.
Use the running Editor from the Quickstart. The examples below belong in your export button's
handler, after onReady. Keep the button disabled while export is running and show any rejected promise as an error.
In Vanilla, superdoc is the instance you created. In React, obtain it inside the handler before using any example:
const superdoc = editorRef.current?.getInstance();
if (!superdoc) return;Download the edited document
await superdoc.export({ exportedName: 'sample-edited' });This starts a download named sample-edited.docx. Open it and confirm that your edit is present. The filename does
not need an extension, and DOCX is already the default format.
For a runnable save, edit, restore, and export flow, use the version-history example. Its Export current DOCX button downloads the document currently open in the Editor.
Return bytes without downloading
Set triggerDownload: false when your application needs the file instead of a browser download:
const docx = await superdoc.export({ triggerDownload: false });For one document without additional files, the result is a DOCX Blob. Export does not upload it or confirm a save.
Use the Load and save guide to send those bytes to your backend and report success
only after storage confirms the write.
Choose independent DOCX policies
V2 exports preserve tracked revisions, comment text and resolution status, and content controls by default. Choose policies for the exported copy without changing the open document or a collaborative room:
const redline = await superdoc.export({
triggerDownload: false,
policies: {
trackedChanges: 'review-preserving',
comments: 'resolve',
contentControls: 'flatten',
},
});| Policy | Values | Effect |
|---|---|---|
trackedChanges | review-preserving (default), final, original | Retain supported revisions, accept them, or reject them in the copy. |
comments | preserve (default), resolve, remove | Keep thread status; resolve every open thread while retaining text, replies, and anchors; or remove comments and their package references. |
contentControls | preserve (default), flatten | Keep controls or unwrap them while retaining their content and formatting. |
The standalone Document API accepts the same policies object through doc.export.toDocx({ policies })
and returns base64 bytes plus a warning report. Its mode alias selects trackedChanges.
Document API export rejects collaborative sessions; use superdoc.export() or the active editor's
exportDocx() for browser collaboration.
Unknown values and conflicting aliases reject before export. Unsupported property or structural revision decisions, a decision that would discard a preserved comment anchor, and transformations of a fenced large document also reject. Handle the error without treating it as a successful export. Review-preserving export remains available for supported documents with those revisions.
Prefer policies in new integrations. The legacy browser isFinalDoc flag is deprecated: true maps to
trackedChanges: 'final', and false maps to review-preserving. It does not select a comment or control
policy. The deprecated commentsType: 'external' maps to comments: 'preserve', and clean maps to
remove. Supplying an alias and a conflicting policy rejects; matching values are accepted. These options
affect the exported copy, so use the review workflow to decide revisions in the live document.
Include related files
To deliver the DOCX alongside another file, supply a Blob and its filename. This example creates its own small
metadata file; it does not require an audit service:
const metadata = new Blob([JSON.stringify({ document: 'sample-edited' })], { type: 'application/json' });
const bundle = await superdoc.export({
exportedName: 'sample-edited',
additionalFiles: [metadata],
additionalFileNames: ['metadata.json'],
triggerDownload: false,
});The result is a ZIP Blob containing sample-edited.docx and metadata.json. Keep the two additional-file arrays
in the same order, with one filename for each file. Omit triggerDownload: false to download sample-edited.zip.
Choose options for the next export
| Option | Default | Effect |
|---|---|---|
exportedName | Editor title | Name the DOCX or ZIP without its extension. |
triggerDownload | true | Download the result; set it to false to return a Blob or ZIP without downloading. |
policies | Preserve all | Select tracked-change, comment, and content-control behavior independently. |
additionalFiles / additionalFileNames | Empty arrays | Include related files in a ZIP. |
exportType defaults to ['docx'], the browser Editor's supported export format.
The v2 Editor does not apply fieldsHighlightColor during export.
Use Version history when your application needs to retain each exported DOCX as a saved version.
Review DOCX support and known limits for this version's preservation, rendering, and editing boundaries.