DocumentViewerElement Class
Description
Hosts a document viewer and exposes its supported viewer API through a custom element. The initial `dock`, `view`, `toolbar-docked`, and `show-thumbnail-pane` values may be supplied as readable attributes. The element initializes itself when connected, preserves its controller and document state across temporary disconnects, and cannot be reused after dispose(). 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. Use the native `addEventListener()` method for the lifecycle events `documentViewerLoading` and `documentViewerLoaded` and for the bubbling viewer events `documentLoaded`, `zoomChanged`, and `annotationsChanged`. The viewer event payload is available as `event.detail`; link events can be canceled with the native `event.preventDefault()` method.
Syntax
DocumentViewerElementExamples
Subscribe to events on an existing document viewer element.
const element = document.querySelector("tx-document-viewer");
element.addEventListener("documentLoaded", event => {
console.log(event.detail);
});Members
Properties
| Property | Description |
|---|---|
| annotations | Controls annotation import/export, stamp definitions, and annotation UI. |
| forms | Reads and validates form fields and controls form-field interaction. |
| signatures | Controls the document-signing workflow. |
| StreamType | Stream type constants accepted by save and download operations. |
| toolbar | Controls the main toolbar and its contextual toolbars. |
| trackedChanges | Tracked-change state and toolbar operations. |
| userNames | User names available to annotation and comment workflows. The first entry is treated as the current user. |
Methods
| Method | Description |
|---|---|
| cancelSearch | Clears the active search and its result overlays. |
| dispose | Permanently releases the controller and all resources owned by the element. Calling this method more than once has no effect. A disposed element cannot be initialized again; create a new element instead. |
| downloadDocument | Saves the current document and starts a browser download. |
| find | Searches the current document, ignoring case unless requested otherwise. Search results are produced asynchronously and displayed by the viewer. |
| isSidebarEnabled | Reports whether the left sidebar is currently visible. |
| loadDocument | Loads a Base64-encoded document and replaces the currently displayed document. Provider and rendering failures resolve to `false`. Invalid document data or lifecycle violations may reject the returned promise. |
| nextSearchResult | Selects the next or previous search result. |
| printDocument | Starts the browser print workflow for the current document. |
| saveDocument | Starts saving the current document and returns a DocumentSaveResult. Its base64() or arrayBuffer() method returns the saved data asynchronously. |
| scrollToPage | Scrolls the document viewport to a page. |
| setSubmitCallback | Obsolete. This method will be removed in one of the next versions. Use `element.signatures.setSubmitCallback()`. Sets the callback used by subsequent signature submissions. |
| setZoomFactor | Applies an absolute zoom factor to the document. |
| signatureCancel | Obsolete. This method will be removed in one of the next versions. Use `element.signatures.cancelSigningProcess()`. Cancels the active signature workflow. |
| signaturePadClear | Obsolete. This method will be removed in one of the next versions. Use `element.signatures.clearSignaturePad()`. Clears the current signature data. |
| signatureRetrieve | Obsolete. This method will be removed in one of the next versions. Use `element.signatures.retrieveSignature()`. Restores signature data from browser storage. |
| signatureStore | Obsolete. This method will be removed in one of the next versions. Use `element.signatures.storeSignature()`. Stores current signature data in browser storage. |
| startSignatureProcess | Obsolete. This method will be removed in one of the next versions. Use `element.signatures.startSigningProcess()`. Starts the signature workflow. |
| submit | Obsolete. This method will be removed in one of the next versions. Use `element.signatures.submit()`. Submits the current document through the signature workflow. |
| toggleFullScreen | Toggles browser fullscreen, or toggles window docking when fullscreen is unavailable. |
| toggleMultiplePageView | Toggles whether pages flow into rows when space allows. |
| toggleSelection | Activates, deactivates, or toggles text selection. |
| toggleSidebar | Toggles the left sidebar. |
| toggleToolbar | Toggles the main toolbar. |