procedure LoadDocument;
procedure LoadDocument(Data: Pointer; Size: NativeUInt; Buffered: Boolean = True);
| Data | Pointer. A pointer to the raw PDF data in memory. |
| Size | NativeUInt. The size of the data buffer in bytes. |
| Buffered | Boolean. When True (default), TPdf retains its own copy. When False, the buffer must remain valid until the document is unloaded. |
procedure LoadDocument(const Data: TBytes; Buffered: Boolean = True);
| Data | TBytes. The PDF file content as a byte array. |
| Buffered | Boolean. When True (default), TPdf retains its own copy. When False, the byte array must remain valid and unchanged until the document is unloaded. |
procedure LoadDocument(const Data: TBytes; Index, Count: Integer; Buffered: Boolean = True);
| Data | TBytes. The backing byte array that contains the PDF window. |
| Index | Integer. The zero-based offset of the first PDF byte. |
| Count | Integer. The number of PDF bytes to load. |
| Buffered | Boolean. When True (default), TPdf copies only the selected window. When False, the backing byte array must remain valid and unchanged until the document is unloaded. |
procedure LoadDocument(Data: TMemoryStream; Buffered: Boolean = True);
| Data | TMemoryStream. A TMemoryStream containing the PDF data. |
| Buffered | Boolean. When True (default), TPdf retains its own copy. When False, the stream memory must remain valid until the document is unloaded. |
Opens and loads a PDF into the component. The no-argument overload reads from the
path stored in FileName. The Pointer, TBytes,
and TMemoryStream overloads load directly from in-memory data, bypassing
the file system. The byte-range overload selects an embedded PDF from a larger
container, protocol frame, or reusable receive buffer without creating a temporary
TBytes slice.
When Buffered is True (default), TPdf
copies the supplied bytes into its retained buffer. When False, the caller's
buffer must remain valid and unchanged until UnloadDocument or
Active := False — this avoids an extra copy but requires careful
lifetime management.
The byte-range overload rejects negative values, an Index beyond the data length, or a Count that extends past the remaining bytes. The pointer overload rejects nil when Size is nonzero; the TMemoryStream overload rejects a nil stream before any document state is changed
On success, Active becomes True and all page properties
reflect the first page (PageNumber = 1). On failure, an
EPdfError exception is raised.
// From file
Pdf.FileName := 'C:\docs\file.pdf';
Pdf.LoadDocument;
// From TBytes
var Bytes: TBytes;
Bytes := TFile.ReadAllBytes('file.pdf');
Pdf.LoadDocument(Bytes);
// From a PDF embedded in a larger byte array
Pdf.LoadDocument(Container, PdfOffset, PdfLength);
// From TMemoryStream (unbuffered)
Pdf.LoadDocument(FStream, False);