One open document in a viewer: owns the document, its engine and options and the tile backends (the backend choice), caches page geometry, builds display lists off the UI thread with cancellation and renders tiles onto an IRenderSurface. Framework-neutral: every UI shell (Blazor, WPF, MAUI, Avalonia) drives the same session.
public sealed class DocumentSession : IDisposable, IAsyncDisposable
ISO 32000-2 §7.7.3.3 (pages), §14.11.2 (the crop box is displayed) and §10.7.1 (rendering through display lists). Spec #33 story 54 and viewer capabilities 1, 2 and 5.
Every operation is asynchronous and never blocks its caller: in Background mode the work runs on thread-pool workers; in Cooperative mode (the browser) it runs on the caller's thread in slices with yields between them. Finished tiles are presented on the context that awaited the render. Display lists come from the document's own cache (DisplayListCacheBudget), so the tiles of one page at any zoom share one list. Pages of a remote document (OpenAsync(HttpClient, Uri)) are prefetched before use, which is how a browser reaches them (PrefetchAsync(Int32, CancellationToken)).
Closing (Dispose() or DisposeAsync()) cancels pending work; once it has stopped, the session disposes its backends and the document, and every pooled tile buffer is back in its pool. DisposeAsync() completes then. Safe to use from several threads; the document must not be edited while the session reads it.
kind:method, kind:property, kind:ctor. Press Esc to clear.DocumentGets the document. The session owns it and disposes it when it closes.IsClosedGets a value indicating whether the session has been closed.PageCountGets the number of pages.RemoteRendererGets the renderer that draws the tiles it accepts outside the viewer's thread, if the options selected one.StatisticsGets what the session is doing and holding right now.BeginEdit()Starts an edit of Document on the calling thread (the UI thread): in Background mode it stops the reads that workers have in progress (page loads, display-list builds and page-model loads, which start again after the edit) and holds new ones until the returned scope is disposed. Edit the document only inside such a scope while the session reads it; AnnotationLayer's edits take one themselves.Dispose()Closes the session: cancels pending work; the backends and the document are released once that work has stopped.DisposeAsync()Closes the session and completes once pending work has stopped and every resource is released.GetDisplayListAsync(Int32, DisplayLayers, CancellationToken)Returns a page's display list, built off the UI thread (or after a yield in cooperative mode) and kept in the document's cache, so every tile of the page at every zoom replays the same list.GetPageMetricsAsync(Int32, CancellationToken)Returns a page's geometry, loading the page first if needed (a remote page is prefetched), and caches it.GetPageTileAsync(Int32, Double, Int32, CancellationToken)Returns the tile that covers a whole page at a scale.Open(Stream, ViewerOptions?)Opens a document from a stream, which the caller keeps open for the session's lifetime and disposes after it.Open(Stream)Opens a document from a stream with default options; the caller keeps the stream open for the session's lifetime.Open(ReadOnlyMemory<Byte>, ViewerOptions?)Opens a document held in memory.Open(ReadOnlyMemory<Byte>)Opens a document held in memory with default options.Open(String, ViewerOptions?)Opens the document at a path.Open(String)Opens the document at a path with default options.OpenAsync(Stream, ViewerOptions?, CancellationToken)Opens a document from a stream asynchronously (a browser file or a network stream): a stream that cannot seek is read into memory without blocking.OpenAsync(Stream)Opens a document from a stream asynchronously with default options.OpenAsync(HttpClient, Uri, ViewerOptions?, CancellationToken)Opens a remote document over HTTP range requests, first page first: pages are fetched as they are needed, and before each use the session prefetches what the page needs, so this works where synchronous fetching is impossible (the browser).OpenAsync(HttpClient, Uri)Opens a remote document over HTTP range requests with default options, first page first.RenderPageAsync(Int32, Double, IRenderSurface, CancellationToken)Renders a whole page at a scale as one tile and presents it to surface.RenderTileAsync(Tile, IRenderSurface, CancellationToken)Renders one tile from the page's cached display list and presents it to surface on the awaiting context. A render cancelled by its token or by closing the session never reaches the surface.TryGetPageMetrics(Int32, out PageMetrics)Returns a page's cached geometry, if it has been loaded.