PDFium Delphi Component 文件

Active 屬性

元件: TPdfView  ·  單元: PDFium
啟用或停用檢視器,開啟綁定的 PDF 文件並繪製選定頁面

Syntax

property Active: Boolean; // default False

Description

把 Active 設為 True 會指示檢視器載入相關聯 Pdf 元件所參照的文件、開啟 PageNumber 所指的頁面,並觸發重繪。設為 False 則會關閉頁面、釋放快取的 text-page 控制代碼、丟棄尋找工作階段,並清空可見區域

Active 是檢視器的總開關。與文件相關的屬性(例如 PageCount、PageWidth、PageLabel)以及索引式存取子(Character、Bitmap、WebLink 等),只有在 Active 為 True 且連結的 Pdf 執行個體已載入文件時,才會傳回有意義的值

若 Pdf 是 nil,檢視器會在第一次把 Active 設為 True 時建立並持有內部的 TPdf 執行個體,因此最精簡的程式只要把它指向檔案,再直接呼叫 PdfView1.Pdf.FileName := ...; PdfView1.Active := True; 即可

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