JavaScript API
Code that runs in the browser controls the Document Editor and the Document Viewer through two JavaScript objects: TXTextControl for the editor and TXDocumentViewer for the viewer. Their references list every object, property, method and event with its syntax and parameters. Both APIs are the same in every frontend, whether the component comes from the ASP.NET Core HTML helper, a plain JavaScript page or the Angular or React packages, and the Blazor component of the Document Editor works with the same TXTextControl object.
The two objects are independent APIs with different conventions. Knowing which one you are working with, and how it returns results, makes the reference pages easier to read.
The Two APIs
| Document Editor | Document Viewer | |
|---|---|---|
| Object | TXTextControl | TXDocumentViewer |
| What it controls | The document in the editor: text, formatting, tables, images, fields, sections, tracked changes, comments, the selection and the ribbon | The displayed document: loading and saving, search, printing, zoom, annotations, form fields, tracked changes, signatures and the toolbar |
| Ready for your code | After the editor has raised textControlLoaded | After the viewer has raised documentViewerLoaded on window |
| How methods return results | Asynchronous methods pass their results to callback functions | Loading and saving return promises; most other members return their result directly |
| Events | addEventListener of TXTextControl | addEventListener of TXDocumentViewer |
| Guide | JavaScript API in Document Editor | JavaScript API in Document Viewer |
Enumerations of the editor are properties of its object, such as TXTextControl.StreamType, and the viewer has its own, such as TXDocumentViewer.StreamType.
How the Reference Is Organized
Each API has a page per object. The main objects, TXTextControl and TXDocumentViewer, lead to the objects your code reaches through their properties, such as the tables of a document or the annotations in the viewer. The page of an object lists its properties, methods and events. The page of a member shows its syntax, its parameters, the value or callback it returns and the version it was introduced in.
The Document Editor's reference also documents the callback types and the objects that event handlers receive, such as DocumentLoadedEventArgs. The objects of the Document Viewer's reference are fewer: the viewer, its toolbar, annotations, forms, tracked changes, signatures and the settings objects for loading, saving and signing documents.
Find the Right Page
| If you want to | Read |
|---|---|
| Understand callbacks, the object model and when the editor's object exists | JavaScript API in Document Editor |
| Find the events of the editor and their order during initialization | Events |
| Understand promises and the objects of the viewer | JavaScript API in Document Viewer |
| Handle the events of the viewer | Events |
| Look up a member of the editor | Document Editor |
| Look up a member of the viewer | Document Viewer |
| Configure the Angular or React components that create the editor and the viewer | Angular API or React API |
Pages in This Section
- Document Editor: the reference of the
TXTextControlobject and the objects below it. - Document Viewer: the reference of the
TXDocumentViewerobject and the objects below it.