In order to use the DS Server DocumentViewer with pure HTML and JavaScript, an additional step is required to retrieve the OAuth access token from DS Server. This sample shows how to retrieve the token and how to initialize the viewer on a simple HTML page.

In order to run this application, a DS Server trial token is required. If you don't have a token yet, you can get your token here for free:

Trial Token

This sample implements a DocumentViewer JavaScript class that requests the access token in order to initialize the viewer:

Loading...

This JavaScript file is then referenced in the sample HTML. Additionally, a host element (txViewer) is created and the init() method is called with your trial token credentials:

Loading...

The function getAccessToken is requesting an access token from the OAuth endpoints of DS Server by exchanging the ClientId and ClientSecret for a valid OAuth access token:

Loading...

The returned access token is then used to inject the required DocumentViewer JavaScript in order to call the init() method of DocumentViewer:

Loading...

This initializes the DocumentViewer on the HTML page. The loadDocument TX Text Control DS Server
JavaScript API
TXDocumentViewer Object
loadDocument Method
Loads a document from memory into the DocumentViewer.
method of the JavaScript API can be used to load a document into the created DocumentViewer.

You can test this on your own by downloading the full sample from our GitHub repository.