property Active: Boolean; // default False
Setting Active to True opens and loads the PDF document specified by FileName, using Password if the document is encrypted. When set to False, the document is closed and all associated PDFium resources (pages, fonts, form handles, text pages) are freed
You can also call LoadDocument directly instead of toggling this property; it raises EPdfError on failure. FileName and Password can only be assigned whilst the component is inactive, so switching documents on one TPdf instance means setting Active to False, assigning the new path and setting Active to True again
Setting Active to True does not raise when the file cannot be opened (incorrect path, invalid password, corrupt PDF or unsupported XFA-only form): the component simply stays inactive. Check Active after the assignment and read LastLoadReport, whose Status is plsFailed and whose ErrorMessage describes the failure
Active becomes True — see LoadLibrary if you need to pre-load it from a custom pathPdfView1.Pdf := Pdf1 first; then assign Pdf1.Active := True to open the document and render the first pageActive := False) invalidates every record returned earlier from indexed properties (Annotation, Bookmark, FormFieldInfo, etc.) — do not retain them across an open/close cycle
Pdf1.FileName := 'C:\docs\report.pdf';
Pdf1.Password := ''; // leave empty if not encrypted
Pdf1.Active := True;
if Pdf1.Active then
ShowMessage('Pages: ' + IntToStr(Pdf1.PageCount))
else
ShowMessage('Cannot open: ' + Pdf1.LastLoadReport.ErrorMessage);