Extras
PdfViewer
Bit.BlazorUI.ExtrasPdfReaderPdf
BitPdfViewer is a native pure-C# pdf viewer for Blazor: it parses pdf files and paints their pages as plain HTML/CSS (or onto a canvas), with no browser plugin and no js library. It ships a full reading toolbar - navigation, zoom and fit modes, page layouts, rotation, find, thumbnails, bookmarks, attachments and layers, printing, download, presentation and fullscreen - and everything the toolbar does is on the public API too.
Notes
To use this component, you need to install the
Bit.BlazorUI.Extras(opens in a new tab)
nuget package, as described in the Optional steps of the
Getting started page.
Parsing and rendering run in .NET, so a document never leaves the app. On single-threaded WebAssembly
that work shares the UI thread, which is why every example after the first loads its document on demand.
Overview
Opening a document from a URL, bytes or a stream, the size of the viewer, its toolbar and its side panels.
Basic
A BitPdfSource is the document: FromUrl (fetched through the registered HttpClient),
FromBytes, FromBase64 or FromStreamAsync. AllowDropFile also opens a pdf
dropped onto the viewer.
Page 1 of 3
Dimensions
Height and Width take any CSS length. Unset, the viewer fills its host's width and is at
most 780px tall, shrinking with the viewport. A fit mode re-fits whenever the box resizes.
No document loaded.
Toolbar
ToolbarItems (a flags enum) picks the built-in groups - a group left out takes its find, print or
download shortcut with it - and ShowToolbar hides the bar.
ToolbarStartTemplate and ToolbarEndTemplate add your own content, with the viewer as its
context. OpenFile adds a file picker; handle OnFileOpened to take the picked file
yourself, and MaxOpenFileSize caps what it reads.
No document loaded.
Sidebars
Four side panels: page thumbnails, bookmarks (the document outline), embedded attachments and
optional-content layers. DefaultSidebar picks the one open when a document loads. Thumbnails
render lazily, and a panel with nothing to show keeps its toggle disabled.
No document loaded.
Topics
Everything else about PdfViewer, one page per topic.
- Zoom, layout & renderingZoom modes and limits, scroll and spread modes, finding text in the document, and how pages are rendered.
- Documents & statesReading a document's metadata, opening encrypted documents, and the loading, empty and error states.
- Events & accessibilityThe events a viewer raises, binding the page, zoom and rotation, localized strings, and the keyboard and screen readers.
- API & large documentsDriving the viewer from code, loading a document from a seekable server stream, and fetching it by HTTP Range requests as its pages are needed.
- CustomizationDefaults through BitParams, styling every part of the viewer with classes, styles and CSS variables, and right-to-left layouts.
- API referenceEvery parameter, public member, sub-class, enum and CSS variable of BitPdfViewer.
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.