Products Technologies Demo Docs Blog Support Company

DS Server: Using DocumentEditor in Angular Applications

This quickstart tutorial shows how to use the DocumentEditor of DS Server in Angular applications.

DS Server: Using DocumentEditor in Angular Applications

This quickstart tutorial shows how to use the DocumentProcessing.DocumentEditor in an Angular application.

Prerequisites

  1. Create your free trial token here:

    Create trial token

  2. Install Node.js® and npm, if not done before.

  3. Open a Command Prompt and install the Angular CLI globally by typing in the following command:

    npm install -g @angular/cli

Creating the Project

  1. Open a Command Prompt and create a new project and default app by typing in the following command:

    ng new my-ds-editor-app

    Follow the questions in the command prompt by answering them with "y" to add Angular routing and Enter to confirm CSS as your preferred stylesheet format.

  2. Change into the created folder by typing in the following command:

    cd my-ds-editor-app
  3. Install the DS Server DocumentEditor package by typing in the following command:

    ng add @txtextcontrol/tx-ng-ds-document-editor
  4. Open this folder in Visual Studio Code by typing in the following command:

    code .
  5. In Visual Studio Code, open the file src -> app -> app.component.html, add the following code and save it. Replace the oauthClientID and the oauthClientSecret values with your private trial token keys you created at the beginning of this tutorial.

    <tx-ds-document-editor
       width="1024px"
       height="1024px"
       serviceURL="https://trial.dsserver.io"
       oauthClientID="dsserver.u5NQQHkgjmCRAOeChUVc19zNFJ9aivKz"
       oauthClientSecret="tPGgkutg8oYuSHPbfuRfE5DMf9arUCEg"
       [userNames]="['user1', 'user2']">
    </tx-ds-document-editor>
  6. Open the file src -> app -> app.component.ts and replace the complete file with the following code:

    import { Component, HostListener } from '@angular/core';
    
    declare const TXTextControl: any;
    
    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    
    export class AppComponent {
      title = 'my-ds-editor-app';
    
      @HostListener('document:dsDocumentEditorLoaded')
    
      onDsDocumentEditorLoaded() {
        console.log('The TXTextControl object exists from now on.');
    
        TXTextControl.addEventListener("textControlLoaded", function() {
          var sel = TXTextControl.selection;
          sel.setText("Welcome to DS Server", function() {
            sel.setStart(11);
            sel.setLength(9);
            sel.setBold(true);
            sel.setFontSize(30);
          });
        });         
      }
    }
  7. Back in the command prompt, start the Angular application by typing in the following command:

    ng serve --open

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Angular

Integrate document processing, editing, sharing, collaboration, creation, electronic signatures, and PDF generation into your Angular Web applications.

Learn more about Angular

Related Posts

AngularDocumentEditorDS Server

DS Server: Merging Documents using the DocumentProcessing Web API in Angular

This samples shows how to create a template using the document editor and how to merge it using the DS Server DocumentProcessing Web API in Angular.


AngularASP.NETDS Server

Version 30.0 Live Preview

Still in early beta, we published a live demo that shows some of the new features of TX Text Control 30.0 including comments and the new online document editor ribbon style.


AngularASP.NETDS Server

TX Text Control 30.0 Preview: Improved Online Document Editor Ribbon Design

We are currently working on version 30.0 that is planned to be released in Q4 2021. In this new version, the online document editor will receive an improved ribbon design and additional sidebars.…


AngularASP.NETDocumentViewer

DocumentViewer: Deploying Forms

This sample shows how to deploy a form with form fields using the DocumentViewer in order to collect the completed data.


AngularDocumentViewerDS Server

DS Server: Using DocumentViewer in Angular Applications

This quickstart tutorial shows how to use the DocumentViewer of DS Server in Angular applications.