Products Technologies Demo Docs Blog Support Company

This blog post contains outdated information.

The cited code snippets may be workarounds, and be part of the official API in the meantime.

Getting Started: Document Viewer with Angular CLI v18.0

This article shows how to use the TX Text Control Document Viewer npm package for Angular within an Angular CLI v18.0 application. It uses the trial backend running on our servers, but can also be used to get started with self-hosted applications.

Getting Started: Document Viewer with Angular CLI v18.0

The frequency of Angular releases is high compared to new major releases of .NET. Generally, a major release comes every 6 months and the average support window for major releases is 18 months. Thus, Angular version and application updates are a very typical task for Angular developers.

In order to be compatible with a wider range of releases, we have chosen not to build our packages directly against the latest release. Our components can be installed ignoring peer dependencies and are compatible with the latest version.

Prerequisites

There are two ways to evaluate TX Text Control Document Viewer. Either host your own backend by downloading the TX Text Control .NET Server trial, or create a 30-day trial access token to use a hosted backend:

Creating the Angular Application

This tutorial shows how to create your first Angular application using the TX Text Control document editor.

Prerequisites

  1. Create your free trial access token here:

    Create Access 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

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-viewer-app

    Follow the questions in the command prompt by confirming CSS as your preferred stylesheet format and 'N' to disable Server-Side Rendering and Static Site Generation.

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

    cd my-viewer-app
  3. Install the TX Text Control Document Viewer package by typing in 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.component.ts, add replace the complete content with the following code and save it:

    import { Component } from '@angular/core';
    import { RouterOutlet } from '@angular/router';
    import { DocumentViewerModule } from '@txtextcontrol/tx-ng-document-viewer';
    
    @Component({
      selector: 'app-root',
      standalone: true,
      imports: [RouterOutlet, DocumentViewerModule],
      templateUrl: './app.component.html',
      styleUrl: './app.component.css'
    })
    export class AppComponent {
      title = 'my-viewer-app';
    }
  6. 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:

    <tx-document-viewer
      width="800px"
      height="800px"
      basePath="https://backend.textcontrol.com?access-token=yourtoken"
      documentData="SGVsbG8gdGhlcmU="
      dock="Window"
      [toolbarDocked]="true"
      documentPath="test.docx"
      [isSelectionActivated]="true"
      [showThumbnailPane]="true">
    </tx-document-viewer>

    Backend Server

    The code above uses a hosted demo backend server specified by the basePath property. If you are hosting your own required backend server, replace the URL with your backend endpoint.

  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

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 Viewer

Document Viewer for Angular: SignatureSettings Explained

Learn how to use the SignatureSettings in the Document Viewer for Angular. This article explains how to load a document using JavaScript and how to set up the viewer for digital signatures.


AngularASP.NETJavaScript

Building an ASP.NET Core Backend Application to Host the Document Editor and…

This article explains how to create an ASP.NET Core backend application to host the Document Editor and Document Viewer. This backend application is required to provide the required functionality…


AngularJavaScriptDocument Viewer

Getting Started: Document Viewer with Angular CLI

This article shows how to use the TX Text Control Document Viewer npm package for Angular within a Angular CLI application.


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…