Skip to content
OGE logoOGE

PDF viewer

A read-only PDF viewer over Mozilla's pdf.js: pages drawn as they come near the viewport, page thumbnails, find in document with highlights, zoom by steps or to the width or the page, and printing. pdf.js renders the pages; the viewer adds the chrome, keyboard, text layer for selection and screen readers, and the theme-aware toolbar of the other document viewers.

pdfjs-dist is an optional peer dependency loaded on first use, so an application that never shows a PDF never downloads it. Serve its worker (pdf.worker.min.mjs) and name it with provideOgePdfViewerConfig({ workerSrc }). Fonts are never evaluated as code and scripts and form actions never run. Covered by the same license as the other document viewers.

pdf.js find in document thumbnails print

Getting started

Point source at a PDF. Page Up, Page Down, Home and End move between pages, Ctrl + / − / 0 zoom, and Enter / Shift+Enter in the find box step through the matches.

source toolbar keyboard
Opening the document…

Controlled view

[(pageIndex)], [(zoom)] and [(showThumbnails)] keep the view in your own state: they follow the toolbar and the scrolling, and move the viewer when you set them.

pageIndex zoom showThumbnails

Page 1 · zoom 1

Opening the document…

Bare preview

[toolbar]="false" leaves just the pages, for a preview pane; source takes a File the user picked, read in the browser.

toolbar File
Opening the document…