Using the Angular version of the TX Text Control DocumentEditor, documents can be loaded using the JavaScript API by passing the document as a base64 encoded string. In real-world applications, you might want to load documents from a server-side Web API endpoint.

This sample application uses an ASP.NET Core backend project to provide the WebSocketHandler that also exposes a Web API to load documents from a server.

Web API Controller

Consider the following simple controller implementation with the LoadDocument Http Get method:

Loading...

The method simply loads a document given by it's name into a new instance of the ServerTextControl TX Text Control .NET Server for ASP.NET
TXTextControl Namespace
ServerTextControl Class
The ServerTextControl class implements a component that provide high-level text processing features for server-based applications.
in order to return the document in the internal Text Control format. Technically, the document editor is able to load all supported document types, but this way, we don't have to check the used StreamType TX Text Control .NET Server for ASP.NET
JavaScript API
TXTextControl Object
StreamType Enumeration Enumeration
Determines a certain text format.
and potentially required document checks can be performed completed server-side.

It simply returns an object of type TextControlDocument that contains the document as a base64 encoded string. The model object is defined as follows:

Loading...

Angular TypeScript

The view consists of a Text Control editor and a button to load the document:

Loading...

The following code shows the app.component.ts implementation including the onClickLoadDocument function that calls the loadDocument JavaScript function directly. The function onClickLoadDocument executes an Http GET method on our Web API controller method LoadDocument to retrieve the document:

Loading...

The JavaScript function loadDocument simply loads the given document:

Loading...

Loading documents into TX Text Control

You can test this on your own by cloning or downloading the sample from our GitHub repository.