In a previous tutorial, you learned how to create your first Angular application using the TX Text Control Document Editor.

This tutorial shows how to use the JavaScript API to load and save documents within an Angular application.

Creating the Application

  1. Create a basic Angular application as described in this tutorial:
    Getting Started: Document Editor with Angular CLI

  2. Create a folder named js in the folder src/assets/ and create a new JavaScript file named custom.js.

  3. Add this JavaScript file to the scripts array of the projects architect/build/options element in the angular.json file:

  4. Add the declaration and the methods onClickSave and onClickLoad to the app.component.ts TypeScript file, so that the complete file looks like this:

  5. Finally, add two buttons to the app.component.html with the Angular click handlers:


When executing the application, an HTML document is loaded into the editor when clicking the button Load Document and the button Save Document saves the content as an Adobe PDF document that is downloaded to the browser.

Loading and saving documents in Angular