THotPDF.CopyLoadedSourceToStream
Copies the original loaded PDF bytes with a source-position-preserving bounded read
Declaration
procedure CopyLoadedSourceToStream(Destination: TStream;
MaxBytes: Int64; Checkpoint: TNotifyEvent = nil);
Behavior
This HPDFDoc method copies the retained original source bytes without saving or normalizing the current object graph, and restores the borrowed source stream position on success and failure
Encrypted file loads retain a separate original read handle even after password-based decryption disables the ordinary save shortcut; this method copies the original ciphertext and GetLoadedSourceFileSize reports its size
The retained original handle is released during reload, destruction, and supported in-place incremental publication, and participates in physical source-file alias checks
MaxBytes must be positive and includes the complete source length; a larger source raises EHPDFIncrementalOutputBudget before the first write
Destination must be non-nil and must not alias the loaded stream or the same underlying file, including a hard link; an unavailable original source raises EInvalidOpException
OperationCancellationToken and Checkpoint are checked before and during reads in blocks of at most 64 KiB; the checkpoint receives the THotPDF instance
The method writes at the destination's current position without clearing its existing contents; cancellation, read errors, or destination failures can leave a partial copy, so callers should discard an unsuccessful candidate
The method does not serialize pending object changes and does not establish that the loaded graph still matches the raw source