This guide will show you how to integrate WebViewer Document Viewer & Editor into a Blazor application.
You can also download a ready-to-go sample on GitHub for Blazor server sample or for Blazor wasm sample.
Prior to starting, you should have already installed Node and npm.
In addition,
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.
This guide assumes you already have a Blazor project set up. If you do not, please follow the Blazor quick start guide to get your project scaffolded.
We will use NPM to install WebViewer. If you do not yet have a package.json file, we can create one by running:
You can use whatever values you want when asked.
Once we have a package.json file, we can install WebViewer by running:
We're also going to need to copy the WebViewer assets into the wwwroot
folder so that they can be loaded statically. In package.json
, add the following scripts.
package.json
In our main application file (App.razor
if you followed the Blazor get started tutorial), load the WebViewer library by adding the following script tag somewhere in the <head>
.
Create a new file called WebViewer.razor
in the Components
folder and add the following code.
Components/WebViewer.razor
We can now use this component elsewhere in our app by simply using <WebViewer />
For example, in Components/Pages/Home.razor
, we could load WebViewer by replacing the code in the file with:
Components/Pages/Home.razor
You should now be able to run your app and see WebViewer mounted on the page.
This step is optional, but recommended
WebViewer contains numerous different file types (WASM, GZ, BR) that the server needs to know how to handle. In order to tell Blazor how to serve these assets properly, we need to configure the MIME types.
In Program.cs
, add the following code to apply the proper MIME types.
Program.cs
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales