A PDF viewer for Blazor WebAssembly: pages are rasterized in tiles by the managed software rasterizer on the browser's thread, in slices that leave every animation frame to the browser, and drawn into a canvas; a remote Source is read through HTTP range requests, so page 1 of a linearized file shows before the rest downloads. Pointer, wheel and keyboard input drive the viewer core's InputModel; mouse drags over text select it (copy with the browser's copy command); links and form fields work through the AnnotationLayer; and each loaded page's logical structure is mirrored into an invisible DOM tree in reading order, so screen readers and the keyboard reach page text.
[SupportedOSPlatform("browser")]
public sealed class PdfViewer : ComponentBase, IComponent, IHandleEvent, IHandleAfterRender, IAsyncDisposable
Spec #33 track 6 shell (issue #221), over the viewer core of issues #209 to #220. Accessibility: ISO 32000-2 §14.8 (tagged PDF) and §14.9.3 (alternate descriptions) through AccessibilityBridge. Actions: ISO 32000-2 §12.6.4 — destinations inside the document are followed; every action, URIs included, is reported through OnAction and never performed.
Keys while the viewer has focus: arrows, Page Up/Down, Space, Home/End scroll and turn pages; + and - zoom, 0 fits the width; Tab and Shift+Tab move between links and form fields, Enter activates one; Ctrl/Cmd+A selects all text; Shift+arrows extend a selection; N, H, T, L, G, K, F, D and P move the reading focus to the next element, heading, table, list, figure, link, form field, landmark or page (Shift goes back); Escape clears the selection and the reading focus.
Runs in the browser only (it imports a small JavaScript module from _content/Broadside.Viewer.Blazor).
kind:method, kind:property, kind:ctor. Press Esc to clear.AllowAnnotationEditingGets or sets a value indicating whether presses on markup annotations select and move them (off: they pan or select text).AnnotationsGets the annotation layer of the open document, or null while nothing is open: annotations added, edited or removed and form fields filled through it are redrawn at once.ClassGets or sets extra CSS classes for the viewer's host element (give it a size).HttpClientGets or sets the client that fetches Source; the viewer creates one when it is null.LabelGets or sets the accessible name of the viewer region.LayoutOptionsGets or sets the page layout (mode, cover, gaps, rotation); a change applies to the open document at once and keeps the current page in view.OnActionGets or sets the callback raised for every action a link or a widget requests; the viewer never opens URIs itself.OnErrorGets or sets the callback raised when the document cannot be opened or a page cannot be loaded.OnStateChangedGets or sets the callback raised when the current page, the page count, the zoom or the loading state changes.OptionsGets or sets the viewer options a Source opens with (engine, fonts, credentials, slice budget).SelectionGets the text selection of the open document, or null while nothing is open: select a found match with Select(TextPosition, TextPosition) (after LoadPageAsync(Int32, CancellationToken)) and the viewer draws it.SessionGets or sets a document session the host opened itself (for example from a picked file); it wins over Source and is not disposed by the viewer.ShowAnnotationsGets or sets a value indicating whether annotations and form fields are drawn.SourceGets or sets the address of the document to open; a relative address is resolved against the application's base address.StateGets the current state.TileObserverGets or sets an observer of the tile scheduler's events (tiles started, presented, cancelled, evicted, failed), applied when a document opens: for instrumentation such as time to the first sharp page (#353's measurements).GoToPage(Int32)Scrolls to a page.NextPage()Goes to the next page (or spread).PreviousPage()Goes to the previous page (or spread).Redraw()Draws every tile again, for example after the session's backend changed what it draws with.Reveal(Int32, PdfRectangle)Scrolls the least distance that brings an area of a page into view (a found match, an annotation), or centres it.ShouldRender()Renders only when the viewer's own markup changed (its text layer, status or attributes), not each time the parent re-renders (it does on every page change through OnStateChanged): diffing the text layer of every loaded page would stall a scroll on a phone (#357).ZoomBy(Double)Zooms by a factor about the centre of the viewport.ZoomTo(ZoomMode)Zooms to actual size, the page width or the whole page.