DocumentSession Class

Definition

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

Remarks

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.

Tip: use kind:method, kind:property, kind:ctor. Press Esc to clear.

Properties (5)

Methods (19)