procedure LoadDocument;
procedure LoadDocument(Data: Pointer; Size: Integer; Buffered: Boolean = True);
| Data | Pointer. A pointer to the raw PDF data in memory. |
| Size | Integer. The size of the data buffer in bytes. |
| Buffered | Boolean. When True (default), PDFium copies the data immediately. 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), PDFium copies the data immediately. When False, the buffer must remain valid 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), PDFium copies the data immediately. When False, the buffer 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.
When Buffered is True (default), PDFium immediately
copies the supplied data into its own 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.
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 TMemoryStream (unbuffered)
Pdf.LoadDocument(FStream, False);