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. Assigning FileName while Active is already True automatically reloads the document from the new path, which is the recommended way to swap between PDFs in a single TPdf instance
If the file cannot be opened (incorrect path, invalid password, corrupt PDF, or unsupported XFA-only form) an EPdfError exception is raised. Wrap the assignment in a try/except block for graceful error handling, and inspect E.Message for the PDFium error description
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 blank if not encrypted
try
Pdf1.Active := True;
ShowMessage('Pages: ' + IntToStr(Pdf1.PageCount));
except
on E: EPdfError do
ShowMessage('Cannot open: ' + E.Message);
end;