# Javascript: TXDocumentViewer.init Method

> 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`.

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

---

### Description

Initializes a controller through the legacy browser-global API. The method creates a [DocumentViewerController](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/documentviewercontroller/llms-full.txt) 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`.

### Syntax

```javascript
<Promise.<DocumentViewerController>> TXDocumentViewer.init(<ViewerInitSettings> initSettings, [<boolean> fireDocumentViewerLoadedEvent])
```

### Parameters

| Parameter | Description |
|---|---|
| initSettings | Container and initial viewer settings. |
| fireDocumentViewerLoadedEvent | Optional. Whether to dispatch the `documentViewerLoaded` event after initialization. |

### Return Value

The initialized document viewer controller.

---

## Nearby

- **Previous:** [TXDocumentViewer Object](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/txdocumentviewer/llms-full.txt)
- **Next:** [ViewerEvents Enumerations](https://docs.textcontrol.com/ds-server/reference/javascript-document-viewer/viewerevents/llms-full.txt)
