Skip to content

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.



3 page(s).
100%
sample.pdf
Page 1 of 3
1
Sample PDF

Created for testing PDFObject

This PDF is three pages long. Three long pages. Or three short pages if
you’re optimistic. Is it the same as saying “three long minutes”, knowing
that all minutes are the same duration, and one cannot possibly be longer
than the other? If these pages are all the same size, can one possibly be
longer than the other?

I digress. Here’s some Latin. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec
odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum
imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper porta. Mauris
massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per
conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero.

Sed dignissim lacinia nunc. Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem
at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor.
Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia
aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh.

Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia
nostra, per inceptos himenaeos. Nam nec ante. Sed lacinia, urna non tincidunt mattis, tortor neque
adipiscing diam, a cursus ipsum ante quis turpis. Nulla facilisi. Ut fringilla. Suspendisse potenti.
Nunc feugiat mi a tellus consequat imperdiet. Vestibulum sapien. Proin quam. Etiam ultrices.

Suspendisse in justo eu magna luctus suscipit. Sed lectus. Integer euismod lacus luctus magna.
Quisque cursus, metus vitae pharetra auctor, sem massa mattis sem, at interdum magna augue
eget diam. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae;
Morbi lacinia molestie dui. Praesent blandit dolor. Sed non quam. In vel mi sit amet augue congue
elementum. Morbi in ipsum sit amet pede facilisis laoreet. Donec lacus nunc, viverra nec, blandit
vel, egestas et, augue. Vestibulum tincidunt malesuada tellus. Ut ultrices ultrices enim. Curabitur
sit amet mauris.

Morbi in dui quis est pulvinar ullamcorper. Nulla facilisi. Integer lacinia sollicitudin massa. Cras
metus. Sed aliquet risus a tortor. Integer id quam. Morbi mi. Quisque nisl felis, venenatis tristique,
dignissim in, ultrices sit amet, augue. Proin sodales libero eget ante. Nulla quam. Aenean laoreet.
Vestibulum nisi lectus, commodo ac, facilisis ac, ultricies eu, pede. Ut orci risus, accumsan
porttitor, cursus quis, aliquet eget, justo. Sed pretium blandit orci.

Ut eu diam at pede suscipit sodales. Aenean lectus elit, fermentum non, convallis id, sagittis at,
neque. Nullam mauris orci, aliquet et, iaculis et, viverra vitae, ligula. Nulla ut felis in purus
aliquam imperdiet. Maecenas aliquet mollis lectus. Vivamus consectetuer risus et tortor. Lorem

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.



0 page(s).
100%
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.



Draft
0 page(s).
100%
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.



0 page(s).
100%
No document loaded.

Topics

Everything else about PdfViewer, one page per topic.

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.