Working with DOCX Files

Before you start, ensure you have the Document Authoring library installed and running. For more information, check out the getting started guides. Document Authoring supports DOCX with the additional DOCX Support feature (optional).

Our DOCX support is continually improving, but like any software handling DOCX files, it remains best effort. We recommend always storing documents in DocJSON format after importing them for the first time, rather than repeatedly importing a DOCX file and reexporting it to DOCX to store it. Exporting to DOCX is best used when a document is finalized (if DOCX is needed at all).

Any error handling in the examples below is left out for brevity.

Importing DOCX

Use the DocAuthSystem.importDOCX method:

// Assuming the `docAuthSystem` instance exists.

const document = await docAuthSystem.importDOCX(
	await fetch('/document.docx'),
);

const editor = await docAuthSystem.createEditor(
	document.getElementById('editor'),
	{ document },
);

Exporting DOCX

Use the DocAuthDocument.exportDOCX method:

// Assuming the `editor` instance exists.

const currentDoc = editor.currentDocument();

// `doc` will be an `ArrayBuffer` containing the raw binary data of the DOCX.
const doc = await currentDoc.exportDOCX();