How can I help you?
Getting Started with the Blazor PDF Viewer in Web App
25 May 20268 minutes to read
This section briefly explains how to include the Blazor PDF Viewer component in a Blazor Web App using Visual Studio and Visual Studio Code.
Prerequisites
NOTE
If using interactive render modes (WebAssembly or Auto), install the required .NET workloads for SkiaSharp:
dotnet workload install wasm-tools
- Installs the latest SDK workload (e.g., .NET 10)
- For specific versions, use wasm-tools-net8 or wasm-tools-net9
Create a new Blazor Web App in Visual Studio
Create a Blazor Web App using Visual Studio 2022 via Microsoft Templates or the Syncfusion® Blazor Extension.
NOTE
Configure the appropriate interactive render mode and interactivity location when creating a Blazor Web App.
Install Syncfusion® Blazor SfPdfViewer and Themes NuGet Packages in the App
To add Syncfusion Blazor SfPdfViewer component in the app, open the NuGet package manager in Visual Studio (Tools → NuGet Package Manager → Manage NuGet Packages for Solution), search and install Syncfusion.Blazor.SfPdfViewer and Syncfusion.Blazor.Themes.
If you utilize WebAssembly or Auto render modes in the Blazor Web App, you need to install Syncfusion® Blazor components NuGet packages within the client project.
Alternatively, you can utilize the following package manager command to achieve the same.
Install-Package Syncfusion.Blazor.SfPdfViewer -Version 33.2.3
Install-Package Syncfusion.Blazor.Themes -Version 33.2.3NOTE
Syncfusion® Blazor components are available in nuget.org. Refer to NuGet packages topic for available NuGet packages list with component details. Syncfusion® uses SkiaSharp.Views.Blazor version 3.119.1. Ensure this version is referenced.
Prerequisites
NOTE
If using interactive render modes (WebAssembly or Auto), install the required .NET workloads for SkiaSharp:
dotnet workload install wasm-tools
- Installs the latest SDK workload (e.g., .NET 10)
- For specific versions, use wasm-tools-net8 or wasm-tools-net9
Create a new Blazor Web App in Visual Studio Code
Create a Blazor Web App using Visual Studio Code via Microsoft Templates or the Syncfusion® Blazor Extension.
For example, in a Blazor Web App with the Auto interactive render mode, use the following commands in the integrated terminal (Ctrl+`).
dotnet new blazor -o BlazorWebApp -int Auto
cd BlazorWebApp
cd BlazorWebApp.ClientNOTE
Configure the appropriate interactive render mode and interactivity location when creating a Blazor Web App.
Install Syncfusion® Blazor SfPdfViewer and Themes NuGet Packages in the App
If you utilize WebAssembly or Auto render modes in the Blazor Web App, you need to install Syncfusion® Blazor components NuGet packages within the client project.
- Press Ctrl+` to open the integrated terminal in Visual Studio Code.
- Ensure you’re in the project root directory where your
.csprojfile is located. - Run the following command to install Syncfusion.Blazor.SfPdfViewer and Syncfusion.Blazor.Themes NuGet packages and ensure all dependencies are installed.
dotnet add package Syncfusion.Blazor.SfPdfViewer -v 33.2.3
dotnet add package Syncfusion.Blazor.Themes -v 33.2.3
dotnet restoreNOTE
Syncfusion® Blazor components are available in nuget.org. Refer to NuGet packages topic for available NuGet packages list with component details.
NOTE
Syncfusion® uses SkiaSharp.Views.Blazor version 3.119.1. Ensure this version is referenced.
Add import namespaces
After the package is installed, open the ~/_Imports.razor file from the client project and import the Syncfusion.Blazor and Syncfusion.Blazor.SfPdfViewer namespaces.
@using Syncfusion.Blazor
@using Syncfusion.Blazor.SfPdfViewerRegister Syncfusion® Blazor service
Register the Syncfusion® Blazor service in the ~/Program.cs file of your Blazor Web App.
using BlazorWebAppServer.Components;
using Syncfusion.Blazor;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
builder.Services.AddSignalR(o => { o.MaximumReceiveMessageSize = 102400000; });
builder.Services.AddMemoryCache();
//Add Syncfusion Blazor service to the container.
builder.Services.AddSyncfusionBlazor();
var app = builder.Build();
....using BlazorWebApp.Client.Pages;
using BlazorWebApp.Components;
using Syncfusion.Blazor;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents()
.AddInteractiveWebAssemblyComponents();
builder.Services.AddMemoryCache();
//Add Syncfusion Blazor service to the container
builder.Services.AddSyncfusionBlazor();
var app = builder.Build();
....using BlazorWebAppAuto.Client.Pages;
using BlazorWebAppAuto.Components;
using Syncfusion.Blazor;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents();
builder.Services.AddSignalR(o => { o.MaximumReceiveMessageSize = 102400000; });
builder.Services.AddMemoryCache();
//Add Syncfusion Blazor service to the container
builder.Services.AddSyncfusionBlazor();
var app = builder.Build();
....NOTE
If the interactive render mode is set to WebAssembly or Auto, register the Syncfusion® Blazor service in both ~/Program.cs files of the Blazor Web App. Processing Large Files Without Increasing Maximum Message Size in SfPdfViewer Component
Add stylesheet and script resources
The theme stylesheet and script can be accessed from NuGet through Static Web Assets. Include the stylesheet and script references in the ~/Components/App.razor file.
<head>
<!-- Syncfusion Blazor PDF Viewer control's theme style sheet -->
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" />
</head>
<body>
<!-- Syncfusion Blazor PDF Viewer control's scripts -->
<script src="_content/Syncfusion.Blazor.SfPdfViewer/scripts/syncfusion-blazor-sfpdfviewer.min.js" type="text/javascript"></script>
</body>NOTE
Check out the Blazor Themes topic to explore supported ways (such as static assets, CDN, and CRG) to apply themes in your Blazor application. Also, check out the Adding Script Reference topic to learn different approaches for adding script references in your Blazor application.
Add Syncfusion® Blazor PDF Viewer component
Add the Syncfusion Blazor PDF Viewer (Next-Gen) component in the ~/Components/Pages/*.razor file. If the interactivity location is set to Per page/component in the Web App, define a render mode at the top of the ~/Pages/*.razor file. (For example, InteractiveServer, InteractiveWebAssembly or InteractiveAuto).
NOTE
If the Interactivity Location is set to
GlobalwithAutoorWebAssembly, the render mode is automatically configured in theApp.razorfile by default.
@* desired render mode define here *@
@rendermode InteractiveAutoAdd the Syncfusion® PDF Viewer component in ~/Pages/Index.razor.
@page "/"
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
Height="100%"
Width="100%">
</SfPdfViewer2>NOTE
If the DocumentPath property is not set, the PDF Viewer renders without loading a PDF. Use the Open toolbar option to browse and open a PDF.
- Press Ctrl+F5 (Windows) or ⌘+F5 (macOS) to launch the application. This will render the Syncfusion Blazor PDF Viewer in your default web browser.

You can also experiment directly using the interactive playground below for a quick demo:
NOTE
To learn how to open, view, or interact with PDF files in the PDF Viewer component, see Open and Save. For a hands-on reference with working code examples, explore the sample projects available on GitHub.
See also
-
Getting Started with Blazor PDF Viewer Component in Blazor WASM App
-
Getting Started with Blazor PDF Viewer Component in WSL mode
-
Learn different ways to add script reference in Blazor Application
-
Processing Large Files Without Increasing Maximum Message Size in SfPdfViewer Component
-
.NET 9 Native Linking Issues with SkiaSharp and Emscripten 3.1.56