PDF Viewer
Inline PDF document viewer powered by Mozilla pdf.js. Renders multi-page documents on a canvas with page navigation, zoom controls, optional text search, and a one-click download shortcut. No npm build step or API key required.
Installation
dotnet add package Lumeo.PdfViewer
One-time app setup (AddLumeo(), CSS & JS) is covered in the
installation guide.
Usage
@using Lumeo <PdfViewer />
Lumeo.PdfViewer — install it alongside the core Lumeo
package. pdf.js is loaded on demand from jsDelivr the first time a PdfViewer
mounts; no npm build step is required for consumers.
When to Use
- Embedding contracts, invoices, or reports inline in a Blazor page without leaving the app
- Document preview surfaces where the browser's built-in viewer behaves inconsistently across platforms
- Read-only flows that benefit from page navigation, zoom, and full-text search (e.g. audit trails, e-signatures)
- Dashboards that surface generated PDF reports alongside live data
- Admin panels that need to display uploaded user documents with a controlled, branded UI
Self-hosting pdf.js
By default the viewer lazy-loads pdf.js + its worker from jsDelivr the
first time a PdfViewer mounts. That's the right tradeoff for low-traffic
apps and demos, but it doesn't work behind a strict CSP, on an air-gapped intranet,
or in compliance scenarios where every third-party script call is a no-go.
The Lumeo CLI ships a one-shot installer that vendors pdf.js into
wwwroot/lib/lumeo-vendor/ and wires up
window.lumeoCdn so the runtime loads from your own origin instead of
the CDN:
# 1. Install the Lumeo CLI as a global dotnet tool $ dotnet tool install -g Lumeo.Cli # 2. Vendor pdf.js into wwwroot/lib/lumeo-vendor/ and write the bootstrap $ lumeo deps install --lib pdfjs --write-bootstrap # 3. Include the bootstrap before _content/Lumeo.PdfViewer/js/* in index.html # <script src="js/lumeo-cdn-init.js"></script>
See CDN dependencies for the full list
of self-hostable libraries and the window.lumeoCdn override surface.
For more granular control (custom URL, integrity hash, alternative CDN) you can
set window.lumeoCdn = { pdfJs: "/my/cdn/pdf.min.mjs", pdfJsWorker: "/my/cdn/pdf.worker.min.mjs" };
before the first PdfViewer mounts.
API Reference
PdfViewer
Src accepts a PDF URL or a data: URI (both are loaded via fetch); changing it reloads the document.
Keyboard shortcuts
Focus the canvas area (click once or Tab to it) then use:
| Key | Action |
|---|---|
| PageDown / ArrowRight | Next page |
| PageUp / ArrowLeft | Previous page |
| + / = | Zoom in (+25%) |
| - / _ | Zoom out (−25%) |
role="document"
with aria-label="PDF document" and tabindex="0" so it
receives keyboard focus. The loading overlay uses role="status" with
aria-live="polite". Search match counts are announced via aria-live.