Saves the current document in a certain format and sends the result back asynchronously by calling a given callback function.

Introduced: X13.

<void> TXTextControl.saveDocument(<StreamType> streamType, <SaveDocumentResultCallback> callback, [<SaveSettings> saveSettings], [<ErrorCallback> errorCallback])


Parameter Description
streamType Specifies one of the numerical StreamType values.
callback A function with one parameter. Is called with an argument object of type SaveDocumentResult containing the document data after the document has been saved successfully.
saveSettings Optional. Specifies additional save settings.
errorCallback Optional. Is called when the operation failed with an error.


The following example shows how to save the current document and display the received document data in the console.

TXTextControl.saveDocument(TXTextControl.StreamType.HTMLFormat, function (e) {

Possible console output: 

<?xml version="1.0" ?> 
<html xmlns=""> 

Further Reading

Learn more about the Javascript: TXTextControl.saveDocument Method in the Text Control Blog: