property Active: Boolean; // default False
Setting Active to True instructs the viewer to load the document referenced by the associated Pdf component, open the page identified by PageNumber, and trigger a repaint. Setting it to False closes the page, releases the cached text-page handle, drops the find session, and clears the visible area.
Active is the master switch of the viewer. Document-related properties such as PageCount, PageWidth, PageLabel, and the indexed accessors (Character, Bitmap, WebLink, etc.) only return meaningful values while Active is True and the linked Pdf instance has a document loaded.
If Pdf is nil the viewer creates and owns an internal TPdf instance the first time Active is set to True, so a minimal program can simply call PdfView1.Pdf.FileName := ...; PdfView1.Active := True; after pointing it at a file.
True automatically reloads the new document.True without a valid source (no FileName, no buffer, no stream on the linked TPdf) raises an exception.// Bind to an explicit TPdf and open a file.
PdfView1.Pdf := Pdf1;
Pdf1.FileName := 'C:\docs\sample.pdf';
PdfView1.Active := True;
// React to open/close in code.
if PdfView1.Active then
StatusBar1.SimpleText := Format('%d pages', [PdfView1.PageCount])
else
StatusBar1.SimpleText := 'No document loaded';
// Close the viewer.
PdfView1.Active := False;