The requested page is not available for the requested platform. You are viewing the content for Default platform.

Document Viewer Integration in Angular

  • 3 min to read

You can use the HTML5 Document Viewer in JavaScript with Angular based on the server-side model. You should create two parts: a server (backend) and a client (frontend) part that includes all the necessary styles, scripts, and HTML-templates.


Perform the steps from one of the following topics to prepare a backend application:

This document describes how to create and configure the client part:

  1. Install Node.js and npm if they do not exist on your machine.
  2. Open the console window and install the Angular CLI (command line interface tool) globally.

    npm install -g @angular/cli
  3. Create a new folder to store all the files related to the client-side functionality.

  4. Navigate to the added folder and run the following command in the console to create a new project:

    ng new angular-example

    Refer to the Angular documentation for information on the application's structure and the created files' purposes.

  5. Open the package.json configuration file and add the following packages:

      "dependencies": {
        "devextreme": "~19.1.3",
        "@devexpress/analytics-core": "~19.1.3",
        "devexpress-reporting-angular": "~19.1.3",
  6. In the console, run the following commands to change the directory to the created project's folder and install the packages:

    cd angular-example
    npm install

    You can find all the libraries in the node_modules folder after the installation is completed.

  7. Import DxReportViewerModule in your module (for instance, in the AppModule class) as shown below:

    import { BrowserModule } from '@angular/platform-browser';
    import { NgModule } from '@angular/core';
    import { AppComponent } from './app.component';
    import { DxReportViewerModule } from 'devexpress-reporting-angular';
    declarations: [
    imports: [
    providers: [],
    bootstrap: [AppComponent]
    export class AppModule { }
  8. Use the dx-report-viewer Angular component in your HTML file (for example, app.component.html) as demonstrated below:

        <dx-report-viewer [reportUrl]="reportUrl" height="800px">
            <dxrv-request-options [invokeAction]="invokeAction" [host]="hostUrl"></dxrv-request-options>
  9. In the app.component.ts file, import decorators, link styles and specify the component's options.

    import { Component, ViewEncapsulation } from '@angular/core';
        selector: 'my-app',
        templateUrl: './app.component.html',
        encapsulation: ViewEncapsulation.None,
        styleUrls: [
    export class AppComponent {
        // The URL of a report to open in the Report Designer when the application starts.
        reportUrl: string = 'InvoiceReport';
         // URI of your backend project.
        hostUrl: string = 'http://localhost:11111/';
        // Use this line if you use an ASP.NET MVC backend
        invokeAction: string = 'WebDocumentViewer/Invoke';
        // Uncomment this line if you use an ASP.NET Core backend
        // invokeAction: string = 'DXXRDV';
  10. For the example to work correctly, you should first run a backend project in Visual Studio, and then run the client part.

    Use the command below to launch the server and rebuild the application each time you make changes to the source files:

    ng serve

    Open your browser on http://localhost:4200/ to see the result.