DocumentViewerController Class
Description
Creates the controller for a document viewer hosted in an existing element. Construction only prepares controller state. Call initialize() before using document, layout, toolbar, form, signature, annotation, or viewer-event operations. Call dispose() when the host permanently releases the viewer. A document provider is the component that loads document data and supplies the viewer with pages, text, and document-saving functionality. The viewer can use the server-side provider backed by TX Text Control endpoints or the optional PDF.js provider configured through the `pdfjs` property of DocumentLoadSettings.
Syntax
DocumentViewerControllerExamples
Create and initialize a viewer controller for an existing host element.
const controller = new DocumentViewerController(container, {
resources,
view: 1,
dock: 1
});
await controller.initialize();Members
Constructors
| Constructor | Description |
|---|---|
| DocumentViewerController | Initializes a new instance of the DocumentViewerController class. |
Properties
| Property | Description |
|---|---|
| annotations | Controls annotation import/export, stamp definitions, and annotation UI. Available after initialize() completes. |
| forms | Reads and validates form fields and controls form-field interaction. Available after initialize() completes. |
| signatures | Controls the document-signing workflow. Available after initialize() completes. |
| StreamType | Stream type constants accepted by save and download operations. |
| toolbar | Controls the main toolbar and its contextual toolbars. Available after initialize() completes. |
| trackedChanges | Tracked-change state and toolbar operations. Available after initialize() completes. |
Methods
| Method | Description |
|---|---|
| __init__ | Obsolete. This method will be removed in one of the next versions. Use `controller.initialize()`. Initializes the viewer using the legacy method name. |
| addEventListener | Registers a listener for a public viewer event. |
| cancelSearch | Clears the active search and its result overlays. |
| dispose | Permanently releases all resources owned by the controller. |
| downloadDocument | Saves the current document and starts a browser download. |
| find | Searches the current document, ignoring case unless requested otherwise. |
| initialize | Initializes the viewer DOM and its interaction components. |
| loadDocument | Loads a Base64-encoded document and replaces the currently displayed document. |
| nextSearchResult | Selects the next or previous search result. |
| printDocument | Starts the browser print workflow for the current document. |
| resume | Resumes connection-bound listeners and refreshes layout when initialized. |
| saveDocument | Starts saving the current document and returns a DocumentSaveResult for reading the saved data as Base64 or binary data. |
| scrollToPage | Scrolls the document viewport to a page. |
| suspend | Pauses listeners and resources while the viewer is detached. |
| toggleFullScreen | Toggles browser fullscreen, or toggles window docking when fullscreen is unavailable. |
| toggleSelection | Activates, deactivates, or toggles text selection. |
| toggleSidebar | Toggles the left sidebar. |
| toggleToolbar | Toggles the main toolbar. |