How to display PDFs using Angular
Table of contents
- Build a fully functional PDF viewer in your Angular app
- Enable users to view, annotate, and interact with documents
- Add professional document features without building from scratch
This guide shows how to display a PDF document using Nutrient’s Angular PDF library. Angular is an open source JavaScript framework developed and maintained by Google. It’s written in TypeScript and follows a component-based architecture.
Nutrient’s Angular PDF library
We offer a commercial Angular PDF library that integrates into your web application. Our Angular viewer supports rendering PDF, JPEG, PNG, and TIFF files in any modern browser and on any mobile device without plugins.
Once you’ve displayed a PDF, you can extend your app with powerful document capabilities:
- Annotations — Let users highlight text, add comments, draw, and place stamps
- Form filling — Display and complete interactive PDF forms with text fields, checkboxes, and dropdowns
- Electronic signatures — Capture signatures via drawing, typing, or image upload
- Document editing — Rotate, reorder, merge, and split pages
- Text search — Find and highlight text across documents
- Redaction — Permanently remove sensitive information
All features ship with a polished, customizable UI and dedicated engineering support.
Requirements
- A long-term support (LTS) version of Node.js(opens in a new tab)
- A package manager — npm(opens in a new tab) or Yarn(opens in a new tab)
No additional setup is required to use npm, as it’s included with your Node.js installation.
1. Creating a fresh Angular project
Install the Angular CLI(opens in a new tab) using npm(opens in a new tab) or Yarn(opens in a new tab):
Terminal window npm install -g @angular/cliyarn global add @angular/cliCreate a new Angular application:
Terminal window ng new display-pdfThe
ng newcommand lets you configure the features to include in the initial app. Accept the defaults by pressing the Return key.Change to the project directory:
Terminal window cd display-pdf
2. Adding Nutrient’s Angular PDF library
Add the Nutrient dependency:
Terminal window npm install --save @nutrient-sdk/vieweryarn add @nutrient-sdk/viewerIn the
angular.jsonfile at the root directory, add the following to the assets option:"assets": ["src/assets",{"glob": "**/*","input": "./node_modules/@nutrient-sdk/viewer/dist/nutrient-viewer-lib/","output": "./assets/nutrient-viewer-lib/"}]
With this, Angular will now copy the Nutrient library assets to the assets directory before running your app.
Make sure your server has the Content-Type: application/wasm MIME type set. Read more about this in the Troubleshooting section of our guides.
3. Displaying a PDF document
Copy the PDF document you want to display to the
public/directory. You can use this demo document as an example.Replace the contents of the
app.component.htmlfile in thesrc/app/directory with the following:<div class="app"><!-- We'll mount the Nutrient UI to this element. --><divid="nutrient-container"style="width: 100%; height: 100vh"></div></div>In the
src/app/directory, replace the contents of theapp.component.tsfile with the following:import { Component } from '@angular/core';import NutrientViewer from '@nutrient-sdk/viewer';@Component({selector: 'app-root',templateUrl: './app.component.html',styleUrls: ['app.component.css'],standalone: true,})export class AppComponent {title = 'Nutrient Web SDK Angular Example';ngAfterViewInit() {NutrientViewer.load({// Use the assets directory URL as a base URL. Nutrient will download its library assets from here.baseUrl:location.protocol + '//' + location.host + '/assets/',// Replace [YOUR-DOCUMENT] with your document's namedocument: '/assets/[YOUR-DOCUMENT].pdf',container: '#nutrient-container',}).then((instance) => {// For the sake of this demo, store the Nutrient Web SDK instance// on the global object so that you can open the dev tools and// play with the Nutrient API.(window as any).instance = instance;});}}
The NutrientViewer.load() method creates a new Nutrient instance and returns a Promise resolving to a new NutrientViewer.Instance. It requires a configuration object and returns a rejected promise, NutrientViewer.Error, when the configuration is invalid.
Learn more about the properties of a NutrientViewer.load configuration.
Start the app and open it in your default browser:
Terminal window npm start --openyarn start --open

Next steps
You now have a working PDF viewer in your Angular app. From here, you can:
- Add annotations — Enable users to highlight, comment, and markup documents. See our annotation guide.
- Enable form filling — Let users complete interactive PDF forms. See our form filling guide.
- Capture signatures — Add electronic signature capture to your workflow. See our signature guide.
If you encounter issues, contact our Support team for help.
Try Nutrient for free or explore the live demo to see all features in action.
FAQ
Install Nutrient’s Angular PDF library, copy the PDF to the public/ directory, update app.component.html and app.component.ts, and start the app using npm or Yarn.
Install the Angular CLI using npm or Yarn, create a new project with ng new, accept the default settings, and navigate to the project directory.
Install the Nutrient dependency using npm or Yarn, and modify the angular.json file to include Nutrient assets.