Products Technologies Demo Docs Blog Support Company

Document Editor and Viewer with Newer Versions of Angular CLI

For compatibility reasons, the peer dependencies of the TX Text Control Angular packages are older, but they are backward and forward compatible. This tutorial shows how to use TX Text Control packages with newer versions of Angular.

Document Editor and Viewer with Newer Versions of Angular CLI

For compatibility reasons, the peer dependencies of the TX Text Control Angular packages are older, but they are backward and forward compatible. The reason is simple: Our packages don't use newer features, and we don't want to force users to update their version of Angular just because of our libraries.

This tutorial will show you how to install and use the package if you encounter an error like the one below.

ERESOLVE unable to resolve dependency tree

As an alternative to updating your version of Angular, you can force Angular to use the legacy dependencies. You can use the following tutorial to install the Text Control libraries in more recent versions.

This tutorial uses Visual Studio Code that can be downloaded for free.

Creating the Angular Project

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

    ng new my-tx-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-tx-app
  3. Install the TX Text Control Document Editor package by typing in the following command:

    npm i @txtextcontrol/tx-ng-document-editor --legacy-peer-deps

    To install the TX Text Control Document Viewer package, use the following command:

    npm i @txtextcontrol/tx-ng-document-viewer --legacy-peer-deps
  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.module.ts, add replace the complete content with the following code and save it:

    Document Editor

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    
    import { AppRoutingModule } from './app-routing.module';
    import { AppComponent } from './app.component';
    import { DocumentEditorModule } from '@txtextcontrol/tx-ng-document-editor';
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        AppRoutingModule,
        DocumentEditorModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

    Document Viewer

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    
    import { AppRoutingModule } from './app-routing.module';
    import { AppComponent } from './app.component';
    import { DocumentViewerModule } from '@txtextcontrol/tx-ng-document-viewer';
    
    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
        BrowserModule,
        AppRoutingModule,
        DocumentViewerModule
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
  6. In Visual Studio Code, open the file src -> app -> app.component.html, add replace the complete content with the following code, replace yourtoken with your given Trial Access Token and save it:

    Document Editor

    <tx-document-editor
      width="1000px"
      height="500px"
      webSocketURL="wss://backend.textcontrol.com/TXWebSocket?access-token=yourtoken">
    </tx-document-editor>

    Backend Server

    In the code above, a hosted demo backend server is used specified through the webSocketURL property. If you are hosting your own required backend server, replace the URL with your backend endpoint such as ws://localhost:8080/TXWebSocket.

    Document Viewer

    <tx-document-viewer
            width = "800px"
            height = "800px"
            basePath = "https://backend.textcontrol.com?access-token=yourtoken"
            documentData = "PGh0bWw+PGJvZHk+PHA+VGVzdDwvcD48L2JvZHk+PC9odG1sPg==" 
            dock = "Window"
            [toolbarDocked] = "true"
            documentPath = "test.docx"
            [isSelectionActivated] = "true"
            [showThumbnailPane] = "true">
            </tx-document-viewer>
  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

AngularDocument EditorSPA

Reuse Persistent Document Editor Components in Angular SPA Applications

An Angular Single Page Application (SPA) dynamically updates the web page without reloading by loading all necessary resources once. This article demonstrates how to reuse persistent Document…


AngularASP.NETBlazor

Building an ASP.NET Core Backend (Linux and Windows) for the Document Editor…

This article shows how to create a backend for the Document Editor and Viewer using ASP.NET Core. The backend can be hosted on Windows and Linux and can be used in Blazor, Angular, JavaScript, and…


AngularJavaScriptDocument Viewer

Getting Started: Document Viewer Version 33.0 with Angular CLI 19.0

This article shows how to use the TX Text Control Document Viewer version 33.0 npm package for Angular within an Angular CLI 19.0 application. It uses the trial backend running on our servers, but…


AngularJavaScriptDocument Editor

Getting Started: Document Editor Version 33.0 with Angular CLI 19.0

This article shows how to use the TX Text Control Document Editor version 33.0 npm package for Angular within an Angular CLI 19.0 application. It uses the trial backend running on our servers, but…


AngularASP.NET CoreDocument Editor

Changing the Language in the Angular Document Editor Using the Resource Kit

This article walks you through the process of building a satellite assembly using the Resource Kit to customize the language of the TX Text Control interface in the Angular Document Editor.