Using the Angular version of the TX Text Control DocumentViewer, you can load documents by passing the document as a base64 encoded string to the documentData parameter. In real-world applications, you might want to load documents from a server-side endpoint.
This article explains how to load a document from a Web API running in an ASP.NET Core Web Application.
The API Controller
Consider the following simple controller implementation with the LoadDocument Http Get method:
It simply returns an object of type LoadedDocument that contains the document as a base64 encoded string and the document name. The model object is defined as follows:
Loading a Document on a Button Click
The above method shows how to initialize the DocumentViewer with a document. When a document should be loaded on another action, you can simply call the loadDocument method. The following code shows the home.component.html: