Skip to content
Document Authoring DA  API Docs v1.12.0
npmGitHub

DocAuthDocument

DocAuthDocument:

A document instance. Holds the content and provides methods for saving, exporting to PDF/DOCX, and more.

Create documents via DocAuthEditor and/or DocAuthSystem.

saveDocument(): Promise<object>

Returns the current document in the Document Authoring format as a JavaScript object. This object can be safely persisted.

Promise<object>

DocJSON guide


saveDocumentJSONString(): Promise<string>

Returns the current document in the Document Authoring format as a JSON string. This string can be safely persisted.

Promise<string>


exportPDF(options?): Promise<ArrayBuffer>

Exports a snapshot of the current document as a PDF file.

ExportPDFOptions

Promise<ArrayBuffer>

PDF export guide


exportDOCX(options?): Promise<ArrayBuffer>

Exports a snapshot of the current document as a DOCX file.

ExportDOCXOptions

Promise<ArrayBuffer>

DOCX export guide


export(config): Promise<ArrayBuffer>

Exports a snapshot of the current document in the specified format.

ExportConfig

Promise<ArrayBuffer>

ExportConfig


transaction()

>= v1.10.0Section titled “transaction()”

transaction<T>(callback): Promise<T>

Executes a transaction to programmatically read or modify the document.

T = void

TransactionCallback<T>

A TransactionCallback function that receives a draft document

Promise<T>

A Promise that resolves to the result value from the callback

Provides programmatic access to the document structure through a draft document that can be read and modified. Changes are atomic and isolated until the transaction commits.

The callback executes after all pending transactions and input have been processed. While the callback runs, document access is blocked, preventing any UI interactions until the transaction completes.

await doc.transaction(async ({ draft }) => {
const section = draft.body().sections()[0];
const para = section.content().addParagraph();
para.asTextView().setText('Hello, World!');
return { commit: true };
});

docAuthSystem(): DocAuthSystem

The DocAuthSystem this document is bound to.

DocAuthSystem