PDF viewer

PdfViewerControl

Let users read, search, annotate and fill PDFs without leaving your app.

Overview

PdfViewerControl is a Blazor PDF viewer that lets users read, search, annotate and fill in PDF files in the browser. Use it for contracts, forms and statements: SaveAsync hands the edited file back to your code as bytes, and no PDF content leaves the browser until your application asks for it. It ships in the FlexCore.Documents package with pdf.js and pdf-lib as static assets, so nothing loads from a CDN.

Examples

#Full viewer

Search for FlexCore, open the Details pane for bookmarks and the form on page 2, highlight a selection or add a note, then Download, Print or Save to host with your edits.

Open a PDF document.

Nothing saved yet.

#Read-only, from bytes, driven from the page

Load the same file from bytes, read-only, with Open, annotations, form filling and bookmarks turned off; the buttons call the viewer's methods and its events feed the line below.

Open a PDF document.

Loading… Page 1. No search.

Documentation

ParameterTypeDefaultDescription
DocumentBytesbyte[]?nullThe document as bytes. A different array instance reloads; while bytes are present Url is ignored.
Urlstring?nullFetched by the browser, so a relative path resolves against the page. A failed request is reported through Error.
Passwordstring?nullPassword for an encrypted file. A change reloads the document.
FileNamestring"document.pdf"Name of the downloaded file. A file picked with Open PDF replaces it with its own name.
Heightstring"600px"Height of the body under the two toolbars: the Details pane and the page viewport.
ShowBookmarksbooltrueLists the document outline in the Details pane; an entry with an internal destination jumps to its page, one without is shown disabled.
AllowOpenbooltrueShows the Open PDF picker in the toolbar.
AllowAnnotationsbooltrueShows Highlight selection and Add note. Highlights and notes are kept by the viewer, listed in the Details pane and written into the file on Download, Print and SaveAsync.
AllowFormFillingbooltrueLists the form fields in the Details pane as text boxes, checkboxes and dropdowns. An edit re-renders the page with the new value; edited fields are written into the file on Download, Print and SaveAsync. Read-only fields are listed but not editable.
MaxFileSizelong50*1024*1024Upper bound in bytes for a picked file, DocumentBytes, a fetched Url and the stream SaveAsync reads back. Larger files are refused with "PDF exceeds MaxFileSize."

CssClass, Style, Id, Visible, Enabled and AdditionalAttributes come from FlexControlBase and apply to the root div; Enabled="false" disables every toolbar control and the methods.

An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.