This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/document-authoring/working-with-documents/import.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Import documents

Use DocAuthSystem.import() to open files in Document Authoring. The method detects the format from the file content and optional file name, or you can pass the format explicitly. It returns a DocAuthDocument that you can pass to an editor.

Before you start, make sure the Document Authoring library is installed and running in your app. If you haven’t set it up yet, refer to the getting started guide.

The examples omit error handling. Add it before you use this code in production.

Supported formats

DocAuthSystem.import() reads these formats:

  • docx, dotx, docm — Microsoft Word.
  • rtf — Rich Text Format.
  • odt — OpenDocument Text.
  • markdown — Markdown.
  • txt — Plain text.
  • docjson — Document Authoring’s native format.
  • png, jpeg, bmp, gif, webp — Images.

DOCX support is an optional feature. As with any DOCX handling, import is best effort. After you import a DOCX file, save it as DocJSON and work from that saved document instead of reimporting the original file each time. For more information, refer to the DocJSON guide.

Import with automatic detection

Use automatic detection when a user selects a file and your app doesn’t know the format in advance. Pass the file to DocAuthSystem.import(), and include the file name to help Document Authoring distinguish similar file types:

const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener('change', async () => {
const file = fileInput.files?.[0];
if (!file) {
return;
}
const importedDocument = await docAuthSystem.import(file, {
fileName: file.name,
});
const editor = await docAuthSystem.createEditor(
document.getElementById('editor'),
{ document: importedDocument },
);
});

Import with an explicit format

Pass a format explicitly when you already know it. This helps when the file comes from a source where the extension or MIME type isn’t reliable:

const response = await fetch('/content/guide.md');
const importedDocument = await docAuthSystem.import(response, {
format: 'markdown',
});

Create a document from plain text

Use DocAuthSystem.createDocumentFromPlaintext() when your source is plain text instead of a file:

const text = 'First paragraph\n\nSecond paragraph.';
const textDocument = await docAuthSystem.createDocumentFromPlaintext(text, {
pageSize: 'A4',
});

The method reads \n as a line break, \n\n as a paragraph break, and \t as spaces.

Cancel a long import

Pass an AbortSignal to cancel an import that’s taking too long or is no longer needed:

const controller = new AbortController();
const importedDocument = await docAuthSystem.import(
fetch('/documents/template.odt'),
{ fileName: 'template.odt', abortSignal: controller.signal },
);
// `controller.abort()` cancels the import.

Learn more

Export documents
Write the document to PDF, DOCX, Markdown, RTF, or ODT.

DocJSON
Load and save Document Authoring’s native format.

Programmatic editing
Read and change a document from code.