The WebViewer SDK is expansive, allowing you to do the following with PDFs inside your app:
You can also:
Adding WebViewer to your application allows users to use PDFs, .xlsx, and .docx files without going outside of your application. This reduces reliance on third-party systems, multiple vendors, and file downloads for everyday tasks without compromising control, compliance, or security.
Interact with our showcase demo to test out all of the Apryse WebViewer SDK functionality.
This guide walks you through how to integrate the WebViewer SDK into your Angular application. By the end, you'll be able to render a PDF document in the UI.
You can download a ready-to-go sample on GitHub.
Get started with the Apryse WebViewer SDK in an Angular project by viewing our video. You can also skip the video and follow the steps below to get started.
Video on how integrate the Apryse WebViewer SDK into an Angular app.
Before you start:
First, you'll create your project folder where you'll store your Angular scaffolding later.
1. From the command line interface (CLI), cd
to where you want your new project folder to be:
2. Run the following on the command line, replacing <project-name>
with a project name of your choice:
If you already have an Angular project, skip to step 3.
Within your new project directory, run the following on the command line to install the Angular CLI so you can use the CLI to scaffold (create) your Angular project:
Generate your project next.
Run the following on the command line, replacing <project-name>
with a project name of your choice:
You'll be asked a set of questions during installation. Your answers to most of the questions won't matter to be able to get through the instructions below successfully.
Enter the following on the command line to navigate into your new project:
Enter the following on the command line from within your project directory to install WebViewer into your Angular project:
You'll need to copy the static assets from the webviewer folder required for WebViewer to run using your text editor. The files are located in node_modules/@pdftron/webviewer/public
and must be moved into a location that will be served and publicly accessible. Angular has a built-in mechanism to do this. In Angular, the location of these static assets can be configured in the angular.json
file by updating the assets
array.
Add the following code to the assets
array:
output
value creates a new set of folders and moves the static assets to the lib/webviewer
folder.All default entries in the asset array that exist in the angular.json file should not be deleted. For example, "glob": "**/*", "input": "public".
angular.json
Next, create a WebViewer component that can be used across the app. You'll add code into new folders you create and existing default folders that are part of your Angular project.
1. Create a file called src/app/webviewer/webviewer.component.ts
and add the following code:
path
is the path to the copied static assets.initialDoc
parameter.viewer
.app/webviewer/webviewer.component.ts
2. Create an HTML file called app/webviewer/webviewer.component.html
so you can create an element for WebViewer to bind to. Add the following code to the file:
app/webviewer/webviewer.component.html
The code above adds a div element which contains a reference variable of viewer
that we just used in the TypeScript file. We've also specified some styling.
Now, you can use the component elsewhere in your app.
3. In app/app.component.ts
(or whatever file you want to use the component in), add the WebViewerComponent
to the imports like this:
app/app.component.ts
4. Delete the existing code in the app/app.component.html
file. There's lots of code by default in this file and we don't need any of it.
5. In the file, mount WebViewer:
app/app.component.html
After you've saved all of the files, you'll serve the webpage so you can see the WebViewer UI and the PDF you included to open in WebViewer.
1. Run the following command on the command line from your project directory to run the project.
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.
2. Click the localhost link created in your terminal to view the WebViewer UI and PDF file locally.
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales