Angular PDF Viewer Example

By Hardik Savani May 2, 2024 Category : Angular

Hi Dev,

This article goes in detailed on angular pdf viewer example. This tutorial will give you simple example of angular pdf viewer and editor. step by step explain angular ng2-pdf-viewer example. you'll learn angular ng2-pdf-viewer print.

i will show you how to build pdf viewer in angular 6, angular 7, angular 8, angular 9, angular 10, angular 11, angular 12, angular 13, angular 14, angular 15, angular 16 and angular 17 app.

In this example we will use ng2-pdf-viewer npm package to pdf file viewer in angular 11 application. we will simply install that ng2-pdf-viewer npm package and use PdfViewerModule module to create code.

So, let's see bellow step and get qr code as like bellow screenshot:


Step 1: Create New App

You can easily create your angular app using bellow command:

ng new myNewApp

Step 2: Install ng2-pdf-viewer npm Package

Now in this step, we need to just install ng2-pdf-viewer in our angular application. so let's add as like bellow:

npm install ng2-pdf-viewer --save

Step 3: Import PdfViewerModule

we will import PdfViewerModule module as like bellow code:


import { BrowserModule } from '@angular/platform-browser';

import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';

import { PdfViewerModule } from 'ng2-pdf-viewer';


declarations: [



imports: [




providers: [],

bootstrap: [AppComponent]


export class AppModule { }

Step 4: Update Ts File

here, we need to update ts file as like bellow:


import { Component } from '@angular/core';


selector: 'app-root',

templateUrl: './app.component.html',

styleUrls: ['./app.component.css']


export class AppComponent {

pdfFilePath = "";


Step 5: Update HTML File

here, we need to update html file as like bellow code:


<h1>Angular PDF File Viewer Example -</h1>

<pdf-viewer [src]="pdfFilePath"


style="display: block;"


Now you can run by bellow command:

ng serve

now you can check it.

I hope it can help you...

Tags :