Table of Contents

Namespace PdfEngine.Vector.Parsing

Classes

PdfDataNotLoadedException

The parser needed bytes that are not loaded yet (a PdfEngine.Vector.Parsing.PdfChunkedByteSource over a partly fetched file). PdfRangedDocument catches it, fetches the range and tries again. It is not a syntax error: the recovery paths of the parser (rebuilding a damaged cross-reference table) do not catch it. Its Kind is DataNotLoaded; code that recovers from a PdfVectorException lets this one through.

PdfFileByteSource

File-backed IPdfByteSource with random access over a FileStream.

PdfMemoryByteSource

Memory-backed IPdfByteSource over a byte array or ReadOnlyMemory.

PdfMemoryRangeReader

An IPdfRangeReader over bytes in memory, for tests and for hosts that already have the file.

PdfObjectResolver

Resolves indirect object references from classic xref offsets or modern object streams (/ObjStm) with cycle detection and caching.

PdfRangedDocument

A PDF opened from an IPdfRangeReader without reading the whole file first, as Adobe's and pdf.js's viewers open a large file from a web server that answers range requests.

  1. Opening fetches the end of the file (TailBytes) for the cross-reference data, then the objects of the document's structure: the catalog and the root of the page tree (PdfEngine.Vector.Parsing.PdfClosureKind.Structure), and the tree nodes on the path to page 1. The page tree is lazy (IsLazy, LazyPageTree): the page count is the root's /Count, and each page is found when it is first needed, by its path from the root. A tree whose /Count values do not match its kids is read whole instead (PageTreeFallbackReason). Content streams are resolved when their page is drawn.
  2. RunAsync<T>(int, Func<PdfVectorDocument, CancellationToken, ValueTask<T>>, CancellationToken) fetches the objects one page needs, level by level from the page dictionary (PdfEngine.Vector.Parsing.PdfClosureKind.Page), then runs the operation (draw, read text) on the parsed document synchronously, over the fetched blocks (PdfEngine.Vector.Parsing.PdfChunkedByteSource).
  3. A read that still finds bytes missing is recorded; the bytes are fetched, the document is parsed again over the cache (cheap: nothing is fetched twice) and the operation runs again.
  4. When the cross-reference data is damaged (the parser had to rebuild it by scanning the whole file) or an operation still misses bytes after MaxRounds tries, the whole file is read and the document is opened from memory, as without range loading (FallbackReason says why).

The in-memory path (OpenAsync(byte[], string, PdfSecurityLimits?, CancellationToken, string?, IEnumerable<X509Certificate2>?)) is not changed by any of this. Operations are serialized.

PdfRangedOptions

Settings of a PdfRangedDocument.

Structs

PdfByteRange

A range of bytes of a file: from Start (inclusive) to End (exclusive).

PdfRangeStatistics

How much a PdfRangedDocument has fetched.

Interfaces

IPdfByteSource

Provides bounded random-access byte reading over PDF data sources with 64-bit offsets.

IPdfRangeReader

Random access to a PDF file that is not in memory, for example a file on a web server that answers HTTP range requests. The engine asks only for the ranges it needs (the cross-reference data at the end, then the objects of the pages it draws); see PdfRangedDocument.