For the complete documentation index, see llms.txt. This page is also available as Markdown.

Build an Angular PDF viewer with Apryse WebViewer SDK

This guide shows how to build an Angular PDF viewer using the Apryse WebViewer SDK. You'll learn how to integrate the SDK into an Angular application to render, view, and interact with PDF documents using the WebViewer UI.

You can also download a ready-to-use GitHub sample to get started quickly, or explore the interactive Showcase demo to see WebViewer's full capabilities in action.

Prerequisites

This guide assumes basic familiarity with Angular development. Before you start:

spinner

1. Create an Angular project

In this section, you’ll create a new Angular application using npm. This project provides the foundation for integrating Apryse WebViewer. If you already have an Angular app, skip this and continue to Install WebViewer.

  1. In your terminal, install the Angular CLI globally so you can create and manage Angular projects:

npm install -g @angular/cli
  1. Navigate to the directory where you want to create the project.

  2. Create a new webviewer-angular project using a minimal setup:

ng new webviewer-angular --style=css --ssr=false --defaults

Info

Flags are used to skip prompts during project configuration. The setup sets the CSS stylesheet format, disables server-side rendering (SSR) and prerendering, and accepts all defaults. Select different options if preferred.

  1. Navigate to your new Angular project directory and install dependencies:

2. Install WebViewer

Next, install the Apryse WebViewer SDK using npm. This command adds the WebViewer package to your project, allowing you to integrate the PDF viewer and editor into your Angular application.

After navigating to your webviewer-angular project directory, run the following command to install WebViewer:

3. Copy WebViewer assets

WebViewer requires access to its static assets at runtime, including WebAssembly modules, HTML, and CSS files. These assets are located in node_modules/@pdftron/webviewer/public. To ensure they’re served correctly, make them publicly accessible in your Angular application by configuring the assets array in angular.json. In this section, you’ll copy the required WebViewer assets to a location that Angular serves automatically. For more, see Copying WebViewer static assets.

  1. Open your project in Visual Studio Code and go to the angular.json file.

  2. In the angular.json file, update the assets array to include the following and save:

The output value creates a new set of folders and moves the static assets to the lib/webviewer folder.

Info

You can add multiple entries to the assets array, each with its own input path. Don't modify or remove the default entries in angular.json. For example, keep entries such as {"glob": "**/*", "input": "public"}.

4. Create the PDF viewer

In this section, you'll add WebViewer to your Angular app by creating a component and initializing the viewer. This mounts the WebViewer UI and loads a document in your application.

  1. Create a webviewer folder in your project's src directory:

  1. Create webviewer.ts and webviewer.html files in the webviewer folder:

  1. In Visual Studio Code, add this code to the webviewer.ts file and save:

Info

If you're signed in with an Apryse account, your license key is automatically prepopulated in all code snippets.

  1. Add this code to the webviewer.html file and save:

  1. Replace the src/app/app.ts file with the following and save:

  1. Replace the src/app/app.html file with the following and save:

5. Verify your output

You can now load and display a PDF document in the WebViewer UI. Run your Angular application to launch WebViewer and see the PDF in your browser.

  1. From your project directory, run the following command to start the application:

Info

You may get a warning message in the command line, as the project runs, that you're not using RouterOutlet correctly. You can ignore the warning.

A successful output looks similar to:

  1. Open the localhost URL from your terminal to view the WebViewer UI and PDF document.

Get started video

In this 5-minute video, learn how to install and integrate the Apryse WebViewer SDK into an Angular project.

Integrate the WebViewer SDK in an Angular (v20+) application.

Next steps

UsageGuidesSamplesAPI docs

Last updated

Was this helpful?