---
title: "Export documents"
canonical_url: "https://www.nutrient.io/guides/document-authoring/working-with-documents/export/"
md_url: "https://www.nutrient.io/guides/document-authoring/working-with-documents/export.md"
last_updated: "2026-07-08T00:00:00.000Z"
description: "Export the current Document Authoring document to PDF, PDF/A, DOCX, Markdown, RTF, or ODT with `DocAuthDocument.export()`."
---

# Export documents

Use [`DocAuthDocument.export()`](https://www.nutrient.io/api/document-authoring/types/docauthdocument/#export) to export the document currently shown in an editor. Pass the target format in the export configuration. The method returns an `ArrayBuffer` with the file bytes, which you can download, upload, or store.

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](https://www.nutrient.io/sdk/document-authoring/getting-started.md) guide.

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

## Supported formats

[`DocAuthDocument.export()`](https://www.nutrient.io/api/document-authoring/types/docauthdocument/#export) writes these formats:

- `pdf` — PDF, including PDF/A.

- `docx` — Microsoft Word.

- `markdown` — Markdown.

- `rtf` — Rich Text Format.

- `odt` — OpenDocument Text.

Get the document from the editor with [`currentDocument()`](https://www.nutrient.io/api/document-authoring/types/docautheditor/#currentdocument) before you export it:

```js

const currentDoc = editor.currentDocument();

```

## Export to PDF

Pass `format: 'pdf'` to export the document as a PDF:

```js

const pdf = await currentDoc.export({ format: 'pdf' });

```

For long-term archiving, set `PDF_A` to produce a PDF/A-compliant file:

```js

const pdfa = await currentDoc.export({ format: 'pdf', PDF_A: true });

```

## Export to DOCX

Pass `format: 'docx'` to export the document as a DOCX file:

```js

const docx = await currentDoc.export({ format: 'docx' });

```

DOCX export is best effort, so use it for finalized documents. For everyday saving, store DocJSON instead. For more information, refer to the [DocJSON](https://www.nutrient.io/guides/document-authoring/working-with-documents/docjson.md) guide.

## Export to Markdown, RTF, or ODT

Pass the target format to export Markdown, RTF, or ODT:

```js

const markdown = await currentDoc.export({ format: 'markdown' });
const rtf = await currentDoc.export({ format: 'rtf' });
const odt = await currentDoc.export({ format: 'odt' });

```

## Download an exported file

`export()` returns raw bytes, not a download. To save the result on the user’s device, wrap the bytes in a `Blob`, create an object URL, and click a temporary link:

```js

const pdf = await currentDoc.export({ format: 'pdf' });

const url = URL.createObjectURL(new Blob([pdf], { type: 'application/pdf' }));
const link = document.createElement('a');
link.href = url;
link.download = 'document.pdf';
link.click();
URL.revokeObjectURL(url);

```

## Cancel a long export

Pass an `AbortSignal` to cancel an export in progress:

```js

const controller = new AbortController();

const markdown = await currentDoc.export({
  format: 'markdown',
  abortSignal: controller.signal,
});

// `controller.abort()` cancels the export.

```

## Learn more

**[Import documents](https://www.nutrient.io/guides/document-authoring/working-with-documents/import.md)**\
Open DOCX, PDF, RTF, ODT, Markdown, and image files.

**[DocJSON](https://www.nutrient.io/guides/document-authoring/working-with-documents/docjson.md)**\
Load and save Document Authoring’s native format.

**[Programmatic editing](https://www.nutrient.io/guides/document-authoring/editing-content/programmatic-editing.md)**\
Read and change a document from code.
---

## Related pages

- [Import and export documents](/guides/document-authoring/working-with-documents/overview.md)
- [Import documents](/guides/document-authoring/working-with-documents/import.md)
- [First-class JSON support with DocJSON](/guides/document-authoring/working-with-documents/docjson.md)

