OpenAsync(HttpClient, Uri, CancellationToken) Method

Definition

Namespace Broadside
Assembly Broadside.dll

Opens the remote PDF file at uri through HTTP range requests: the end of the file first, then only the byte ranges of the objects in use. A server that does not serve ranges sends the whole file, which is then read like a stream.

public Task<PdfDocument> OpenAsync(HttpClient httpClient, Uri uri, CancellationToken cancellationToken)

Parameters

httpClient
HttpClient

The client the requests go through; not disposed. It stays in use until the document is disposed.

uri
Uri?

The file's address.

cancellationToken
CancellationToken

Cancels the requests made while opening.

Returns

Task<PdfDocument>
The document, with its structure, catalog and page tree fetched. Dispose it when done. Before reading a page synchronously where SynchronousRangeFetch is off (always on the browser), await PrefetchAsync(CancellationToken).

Remarks

ISO 32000-2 §7.5.1 and §7.5.4 (random access through the cross-reference table, read from the end of the file); spec #33, viewer capability 5; RFC 9110 §14 (range requests). Reading stays synchronous; fetching is asynchronous only at open and prefetch. Bytes are fetched in blocks of RangeBlockSize and kept up to RangeCacheLimit. Credentials for an encrypted file are taken from the options.