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

Integrate WebViewer into Blazor

This sample shows how to integrate the Apryse WebViewer into a Blazor project using the Blazor server-side application template.

WebViewer provides a slick out-of-the-box responsive UI that enables you to view, annotate and manipulate PDFs and other document types inside any web project.

Click the button below to view the full project in GitHub.

webviewerScripts.js
window.webviewerFunctions = {
    initWebViewer: function () {
        const viewerElement = document.getElementById('viewer');
        WebViewer({
            path: 'lib',
            initialDoc: 'https://pdftron.s3.amazonaws.com/downloads/pl/demo-annotated.pdf', // replace with your own PDF file
        }, viewerElement).then((instance) => {
            // call apis here
        })
    }
};
Webviewer.razor
@page "/webviewer"
@inject IJSRuntime JSRuntime

<h1>WebViewer</h1>
<div id='viewer' style='width: 1024px; height: 600px; margin: 0 auto;'></div>

@code {
    protected override async void OnAfterRender(bool firstRender)
    {
      if (firstRender) {
        await JSRuntime.InvokeAsync<object>("webviewerFunctions.initWebViewer");
      }
    }
}