How can I help you?
Migration from PDF Viewer (Classic) to SfPdfViewer
12 Feb 20265 minutes to read
Why PDF Viewer (Classic) to PDF Viewer control
Migrating to SfPdfViewer delivers better performance and a simplified deployment model. Scrolling, page navigation, and printing are optimized for a smoother user experience. SfPdfViewer also removes the WebAssembly server service dependency required by the classic viewer, reducing app complexity and maintenance.
-
Enhanced performance:
Experience faster scrolling, more responsive page navigation, and improved printing throughput for large documents. -
No server service dependency:
SfPdfViewer does not require a separateServiceUrlor server-side WebAssembly service; client-side rendering is handled by the component. -
Unified package across platforms:
A single package supports Windows, macOS, and Linux, making installation consistent across environments.
NuGet package
To initialize the PDF Viewer component, add the following package references to the project .csproj file.
| PDF Viewer (Classic) |
|---|
|
| PDF Viewer |
|
Script File
To use the PDF Viewer component, add the corresponding script reference in the app host page (Host.cshtml or Layout.cshtml) based on the framework version.
NOTE
The same script file is used for both
Server applicationandWebAssembly applicationfor the PDF Viewer component.
| PDF Viewer (Classic) |
|---|
|
| PDF Viewer |
|
Program.cs
Add the following to the Program.cs file to register Syncfusion Blazor services. For WebAssembly apps, enable in-memory caching as shown in the comment.
| PDF Viewer (Classic) |
|---|
|
| PDF Viewer |
|
Index.razor
To render the PDF Viewer component, add the following code in the Index.razor file. In the newer viewer, the ServiceUrl is not required; specify only the DocumentPath and layout attributes.
| PDF Viewer (Classic) |
|---|
|
| PDF Viewer |
|
Project.cs
For WebAssembly applications, include the following properties in the project .csproj file to ensure proper functionality and compatibility.
| PDF Viewer |
|---|
|
NOTE
For WebAssembly applications, install the SkiaSharp.NativeAssets.WebAssembly NuGet package.
NOTE
When hosting in certain environments (for example, Azure App Service), consider using SkiaSharp.Views.Blazor instead of SkiaSharp.NativeAssets.WebAssembly. Align native asset versions in the project file with the installed package version.