# TXDocumentViewer Object

> Legacy browser-global entry point for the TX Text Control Document Viewer. The browser exposes this namespace as `window.TXDocumentViewer`. Before initialization it provides the init() method. After initialization it references the same object as the most recently created DocumentViewerController while retaining the `init()` method for compatibility. The controller's public methods, properties, and namespaces are therefore available directly through `window.TXDocumentViewer` after initialization. Modern integrations should use the ES module or the DocumentViewerElement custom element instead.

- **Product:** DS Server
- **Section:** Reference
- **Kind:** Object
- **Path:** DS Server > Reference > JavaScript API - Document Viewer > TXDocumentViewer Object
- **441 words**
- **Web URL:** https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/txdocumentviewer/
- **LLMs URL:** https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/txdocumentviewer/llms.txt
- **LLMs-Full URL:** https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/txdocumentviewer/llms-full.txt

---

### Description

Legacy browser-global entry point for the TX Text Control Document Viewer. The browser exposes this namespace as `window.TXDocumentViewer`. Before initialization it provides the [init()](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/txdocumentviewer/llms-full.txt) method. After initialization it references the same object as the most recently created [DocumentViewerController](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/documentviewercontroller/llms-full.txt) while retaining the `init()` method for compatibility. The controller's public methods, properties, and namespaces are therefore available directly through `window.TXDocumentViewer` after initialization. Modern integrations should use the ES module or the [DocumentViewerElement](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/documentviewerelement/llms-full.txt) custom element instead.

### Syntax

```javascript
TXDocumentViewer
```

### Examples

The following example demonstrates `TXDocumentViewer` in a practical Document Viewer workflow. The TXDocumentViewer JavaScript object provides a public API to manipulate the document viewer via JavaScript functions in the browser.

```javascript
TXDocumentViewer.addEventListener("annotationsChanged", function() {
    console.log("The Document Viewer annotations changed.");
});
```

---

## In This Section

- [Javascript: TXDocumentViewer.init Method](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/txdocumentviewer/init-method/llms-full.txt): Initializes a controller through the legacy browser-global API. The method creates a DocumentViewerController for the supplied container. If `viewerSettings.documentData` is provided, the document is loaded during initialization. The global then references the same controller instance and keeps this method available as `TXDocumentViewer.init()`. The controller's public API can subsequently be accessed directly through `TXDocumentViewer`.

---

## Nearby

- **Previous:** [Javascript: TrackedChanges.showToolbar Method](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/trackedchanges/showtoolbar-method/llms-full.txt)
- **Next:** [Javascript: TXDocumentViewer.init Method](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/txdocumentviewer/init-method/llms-full.txt)
