Skip to main content

Blazor PDF Viewer

The Blazor PDF Viewer component allows users to view PDF files directly in the browser, without relying on third-party browser tools or extensions.

Parameters

NameTypeDefaultRequiredDescriptionAdded Version
Urlstringnull✔️Gets or sets the PDF URL.1.11.0

Callback Events

EventDescriptionAdded Version
OnDocumentLoadedThis event fires immediately after the PDF document is loaded.1.11.0
OnPageChangedThis event fires immediately after the page is changed.1.11.0

Examples

Basic usage

Blazor Bootstrap: Blazor PDF Viewer Component - Basic usage
<p>@eventLog</p>

<PdfViewer Class="mb-3"
Url="https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf"
OnDocumentLoaded="OnDocumentLoaded"
OnPageChanged="OnPageChanged" />
@code {
private string eventLog { get; set; } = $"Last event: ..., CurrentPage: 0, TotalPages: 0";

private async Task OnDocumentLoaded(PdfViewerEventArgs args)
=> eventLog = $"Last event: OnDocumentLoaded, CurrentPage: {args.CurrentPage}, TotalPages: {args.TotalPages}";

private async Task OnPageChanged(PdfViewerEventArgs args)
=> eventLog = $"Last event: OnPageChanged, CurrentPage: {args.CurrentPage}, TotalPages: {args.TotalPages}";
}

See demo here.