THotPDF.CopyLoadedSourceToStream
Copies the original loaded PDF bytes using a bounded read that preserves source positions
Declaration
procedure CopyLoadedSourceToStream(Destination: TStream;
MaxBytes: Int64; Checkpoint: TNotifyEvent = nil);
Behaviour
This HPDFDoc method copies the retained original source bytes without saving or normalising 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 whilst 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 covers 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, a hard link included; an unavailable original source raises EInvalidOpException
OperationCancellationToken and Checkpoint are checked before and during reads carried out 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 serialise pending object changes and does not establish that the loaded graph still matches the raw source