Skip to content

WebNinjaDeveloper.com

Programming Tutorials




Menu
  • Home
  • Youtube Channel
  • Official Blog
  • Nearby Places Finder
  • Direction Route Finder
  • Distance & Time Calculator
Menu

Angular 14 Render PDF Documents Viewer Using ngx-extended-pdf-viewer Library in Browser (TypeScript)

Posted on January 20, 2023

 

 

Welcome folks today in this blog post we will be rendering pdf documents in browser using ngx-extended-pdf-viewer library in TypeScript. All the full source code of the application is shown below.

 

 

Get Started

 

 

In order to get started you need to make a new angular project using the below command as shown below

 

 

ng new sampleapp

 

 

cd sampleapp

 

 

npm i ngx-extended-pdf-viewer

 

 

And after that you will see the below directory structure of the angular app as shown below

 

 

 

 

Now inside the app.module.ts file and copy paste the following code

 

 

app.module.ts

 

 

TypeScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import { NgxExtendedPdfViewerModule } from 'ngx-extended-pdf-viewer';
 
 
 
@NgModule({
  declarations: [AppComponent],
  imports: [
    BrowserModule,
    NgxExtendedPdfViewerModule
  ],
  providers: [],
  bootstrap: [AppComponent],
})
export class AppModule {}

 

 

And inside the app.component.html file and copy paste the following code

 

 

app.component.html

 

 

1
2
3
4
5
6
7
8
9
10
11
<ngx-extended-pdf-viewer
[src]="'assets/sample.pdf'"
[useBrowserLocale]="true"
[textLayer]="true"
[showHandToolButton]="true"
[showPresentationModeButton]="true"
[(page)]="page"
[(pageLabel)]="pageLabel"
[showDownloadButton]="false"
>
</ngx-extended-pdf-viewer>

 

 

As you can see in the above html code we are using the ngx-extended-pdf-viewer directive we are passing the src property where we are passing the path of the pdf file to render and then we are providing the page number to load.

 

Recent Posts

  • Android Java Project to Crop,Scale & Rotate Images Selected From Gallery and Save it inside SD Card
  • Android Kotlin Project to Load Image From URL into ImageView Widget
  • Android Java Project to Make HTTP Call to JSONPlaceholder API and Display Data in RecyclerView Using GSON & Volley Library
  • Android Java Project to Download Youtube Video Thumbnail From URL & Save it inside SD Card
  • Android Java Project to Embed Google Maps & Add Markers Using Maps SDK
  • Angular
  • Bunjs
  • C#
  • Deno
  • django
  • Electronjs
  • java
  • javascript
  • Koajs
  • kotlin
  • Laravel
  • meteorjs
  • Nestjs
  • Nextjs
  • Nodejs
  • PHP
  • Python
  • React
  • ReactNative
  • Svelte
  • Tutorials
  • Vuejs




©2023 WebNinjaDeveloper.com | Design: Newspaperly WordPress Theme