DS Server

Javascript: DocumentViewerController.saveDocument Method

Method

Description

Starts saving the current document and returns a DocumentSaveResult for reading the saved data as Base64 or binary data.

Syntax

<DocumentSaveResult> DocumentViewerController.saveDocument([<StreamType> streamType], [<DocumentSaveSettings> settings])

Parameters

ParameterDescription
streamType

Optional. Requested output format.

settings

Optional. Form-field and annotation embedding options.

Return Value

Result used to read the saved document data.

Examples

The following example demonstrates TXDocumentViewer.saveDocument in a practical Document Viewer workflow. Saves the loaded document in a specific format and with certain settings.

async function exportCompletedFormAsPdf() {
    const saveSettings = {
        mergeFormFields: true,
        embedAnnotations: true
    };
    const saveResult = await TXDocumentViewer.saveDocument(
        TXDocumentViewer.StreamType.AdobePDF,
        saveSettings
    );
    const documentBase64 = await saveResult.base64();
    console.log("Exported PDF characters:", documentBase64.length);
    return documentBase64;
}