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.
Methods
Section titled “Methods”saveDocument()
Section titled “saveDocument()”Returns the current document in the Document Authoring format as a JavaScript object. This object can be safely persisted.
Returns
Section titled “Returns”saveDocumentJSONString()
Section titled “saveDocumentJSONString()”Returns the current document in the Document Authoring format as a JSON string. This string can be safely persisted.
Returns
Section titled “Returns”exportPDF()
Section titled “exportPDF()”exportPDF(
options?):Promise<ArrayBuffer>
Exports a snapshot of the current document as a PDF file.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”exportDOCX()
Section titled “exportDOCX()”exportDOCX(
options?):Promise<ArrayBuffer>
Exports a snapshot of the current document as a DOCX file.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”export(
config):Promise<ArrayBuffer>
Exports a snapshot of the current document in the specified format.
Parameters
Section titled “Parameters”config
Section titled “config”Returns
Section titled “Returns”transaction<
T>(callback):Promise<T>
Executes a transaction to programmatically read or modify the document.
Type Parameters
Section titled “Type Parameters”T = void
Parameters
Section titled “Parameters”callback
Section titled “callback”A TransactionCallback function that receives a draft document
Returns
Section titled “Returns”Promise<T>
A Promise that resolves to the result value from the callback
Remarks
Section titled “Remarks”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.
Example
Section titled “Example”await doc.transaction(async ({ draft }) => { const section = draft.body().sections()[0]; const para = section.content().addParagraph(); para.asTextView().setText('Hello, World!'); return { commit: true };});TransactionCallbackfor the callback function signatureTransactionResultfor return value optionsProgrammaticfor the full programmatic API namespace
docAuthSystem()
Section titled “docAuthSystem()”docAuthSystem():
DocAuthSystem
The DocAuthSystem this document is bound to.