Scalable and Random-Access PDF Loading
HotPDF keeps large loaded files responsive by delaying stream copies and compressed-object parsing until the data is required
File-backed stream windows
Unencrypted documents opened with LoadFromFile retain immutable stream bodies as source-file ranges
Reads seek to the required range and release the source handle immediately, so the original file remains replaceable on Windows
OpenLoadedStreamSourceSlice creates an independent read-only view over an unfiltered source range without copying or materialising the lazy stream
The first write materialises the stream in memory when it is at or below LoadedStreamMemoryThreshold, or in an owned temporary file when it is larger
Lazy object streams
Each decoded /Type /ObjStm container is indexed by authoritative xref object number without parsing every member during open
Catalog, page-tree, and later link resolution materialise individual members once and reuse their parsed objects
A full rewrite automatically materialises every remaining member, while an unchanged file-backed save can preserve the original bytes directly
ReleaseDecodedStreamsAfterSave releases an object-stream container only after every indexed member is materialised, and ReleaseLoadedDecodedStreamCaches exposes the same safe release pass on demand
Custom random access
Derive from THPDFRandomAccessSource and implement GetSize plus ReadAt to load from HTTP ranges, databases, archives, or virtual storage; override IsRangeAvailable when fetched ranges can arrive independently
LoadFromRandomAccessSource adapts the source to HotPDF's seekable parser and can optionally own the source for the document lifetime
Progressive linearized availability
GetProgressiveLinearizedLoadInfo reads only a bounded first-object probe, validates /L, /O, /E, /N, and /T, and reports the first-page prefix plus main-xref tail ranges required for early display
ReadProgressiveLinearizedFirstPageSection copies the available first-page section in 64 KiB chunks after both required ranges are present, while operation cancellation remains active between reads
THPDFProgressiveLoadStatus distinguishes an unavailable header, a non-linearized or invalid source, missing first-page ranges, first-page readiness, and complete-document readiness
Parallel image and high-ratio stream optimization
OptimizeLoadedStreams can select frmHighRatio to try four deterministic zlib strategies at maximum compression and retain the smallest standards-compatible Flate stream
OptimizeLoadedImagesParallel decodes eligible image streams into bounded adaptive storage, compresses up to the caller's worker limit, and commits results serially in source-object order only when the requested byte saving is achieved
Diagnostics
GetLoadedStreamCacheInforeports source-backed, memory-materialised, and disk-materialised stream countsGetLoadedObjectStreamCacheInforeports indexed and materialised members, cache hits and misses, and retained decoded bytesGetLoadedObjectLifecycleStatisticsseparates clean, dirty, released, and must-write objects
See also: LoadFromRandomAccessSource, GetProgressiveLinearizedLoadInfo, ReadProgressiveLinearizedFirstPageSection, OptimizeLoadedImagesParallel, OpenLoadedStreamSourceSlice, SourceBacked, LoadedStreamMemoryThreshold, ReleaseLoadedDecodedStreamCaches, DecompressAllObjectStreams