PDFium Delphi Component Docs

Active property

Component: TPdfView  ·  Unit: PDFium
Activates or deactivates the viewer, opening the bound PDF document and rendering the selected page

Syntax

property Active: Boolean; // default False

Description

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

Assign a TPdf component to Pdf before setting Active to True. If Pdf is nil or the underlying document fails to open, the viewer remains inactive without raising an exception

Remarks

Example

// 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;

See Also

Pdf, PageNumber, PageCount, ReloadPage, TPdf.Active