DS Server

JavaScript API

Topic

In the browser, your code controls the Document Editor through the TXTextControl object and the Document Viewer through the TXDocumentViewer object. Both scripts come from DS Server, and both objects are the same whether a client library created the component or your own HTML page did. Their references list every object, property, method and event with its syntax and parameters.

The two objects are independent APIs with their own conventions. Knowing how each one is created and when it is ready makes the reference pages easier to use.

The Two APIs

Document EditorDocument Viewer
ObjectTXTextControlTXDocumentViewer
What it controlsThe document in the editor: text, formatting, tables, images, fields, sections, tracked changes, comments, the selection and the ribbonThe displayed document: loading and saving, search, printing, annotations, form fields, tracked changes, signatures and the toolbar
Script on DS Server<serviceURL>/documenteditor/JS/ds-server-document-editor.js<serviceURL>/documentviewer/TextControl/GetResource?Resource=minimized.tx-viewer.min.js
Created byTXTextControl.initTXDocumentViewer.init
EventsaddEventListener of TXTextControl, such as textControlLoadedaddEventListener of TXDocumentViewer
How methods return resultsAsynchronous methods pass their results to callback functionsLoading and saving return promises; most other members return their result directly

Enumerations of the editor are properties of its object, such as TXTextControl.StreamType, and the viewer has its own, such as TXDocumentViewer.StreamType.

How DS Server Connects the Objects

The JavaScript APIs are TX Text Control's, and DS Server adds how the component reaches the server. The client libraries show the settings they pass:

  • Document Editor. TXTextControl.init receives the containerID of the element to fill, the serviceURL of DS Server, authSettings with either clientId and clientSecret or an accessToken, and the editorSettings described by DocumentEditorSettings. serviceURL and authSettings belong to DS Server and are not members of ComponentSettings in the reference.
  • Document Viewer. The script URL carries the access token in the access_token query parameter. TXDocumentViewer.init receives the containerID and viewerSettings, with basePath set to <serviceURL>/documentviewer and the token in oauthSettings.accessToken. DocumentLoadSettings and SignatureSettings are documented in the reference.

The Angular and React components do all of this and tell you when the object exists: the Angular components raise dsDocumentEditorLoaded and dsDocumentViewerLoaded on document, and the React components call onLoad. Without a component, JavaScript in Getting Started loads the editor from a plain HTML page.

How the Reference Is Organized

Each API has a page per object. The main objects, TXTextControl and TXDocumentViewer, lead to the objects your code reaches through their properties, such as the tables of a document or the annotations in the viewer. The page of an object lists its properties, methods and events, and the page of a member shows its syntax, its parameters and the value or callback it returns. The Document Editor's reference also documents the callback types and the objects that event handlers receive.

Find the Right Page

If you want toRead
Look up a member of the editorDocument Editor
Look up a member of the viewerDocument Viewer
Load a document into the editorloadDocument
Offer merge fields from JSON data in the editorloadJsonData
Configure the Angular or React components that create the objectsAngular or React
Configure the Document Editor or Document Viewer in an ASP.NET Core viewASP.NET Core

Pages in This Section

  • Document Editor: the reference of the TXTextControl object and the objects below it.
  • Document Viewer: the reference of the TXDocumentViewer object and the objects below it.