This guide will show you how to integrate WebViewer Document Viewer & Editor into an Angular application.
You can also download a ready-to-go sample on GitHub.
Prior to starting, you should have already installed Node and npm.
Get your Apryse trial key.
Apryse collects some data regarding your usage of the SDK for product improvement.
If you wish to continue without data collection, contact us and we will email you a no-tracking trial key for you to get started.
This video teaches you the fundamentals of installing and initializing WebViewer in any web application. If you wish, you may skip this section and proceed to the steps below.
If you already have an Angular project, skip to step 2.
We will use the Angular CLI to scaffold our project. Run the following code to install it.
Now we can generate our project using the CLI. Run the following command, replacing <project-name>
with a project name of your choice.
You will be asked a set of questions during installation. You may choose whichever options you wish - your choices will not impact the rest of this guide.
Now we can navigate into our new project:
Now we are ready to install WebViewer.
We also have to copy the static assets required for WebViewer to run. The files are located in node_modules/@pdftron/webviewer/public
and must be moved into a location that will be served and publicly accessible.
In Angular, the location of these static assets can be configured in angular.json
by updating the assets
array.
Add the following entry to the assets
array.
angular.json
Now we are ready to create a WebViewer component that can be used across our app.
Create a file called src/app/webviewer/webviewer.component.ts
and add the following code.
app/webviewer/webviewer.component.ts
We also need to create an HTML template so we can create an element for WebViewer to bind to.
app/webviewer/webviewer.component.html
Now, we can use our component elsewhere in our app.
In app/app.component.ts
(or whatever file you want to use our component in), add our WebViewerComponent
to the imports like so:
app/app.component.ts
Then, in the associated html file, we can mount WebViewer.
app/app.component.html
Now if we run our app using ng serve
, you should see WebViewer mounted in your application!
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales