PDFiumPas 說明文件

Active 屬性

此 API 頁面保留識別符號、簽名、程式碼區塊與 PDF 術語原樣
元件: TPdfView  ·  單元: PDFium
啟用或停用檢視器,開啟綁定的 PDF 文件並繪製選定頁面

語法

property Active: Boolean; // default False

說明

Active 設成 True 時,檢視器會載入關聯 Pdf 元件所指向的文件,開啟 PageNumber 指定的頁面,並觸發重繪;設成 False 時則會關閉頁面、釋放快取的 text-page handle、關掉 find session,並清掉可視區域

Active 是檢視器的總開關。像 PageCountPageWidthPageLabel,以及索引式 accessor(CharacterBitmapWebLink 等)只有在 ActiveTrue,而且連結的 Pdf instance 已經載入文件時,才會回傳有意義的值

如果 Pdfnil,檢視器會在第一次把 Active 設成 True 時建立並擁有內部 TPdf instance,所以最小化程式只要先把 PdfView1.Pdf.FileName := ...; PdfView1.Active := True; 指到檔案就行

注意事項

實例

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

另請參閱

Pdf, PageNumber, PageCount, ReloadPage, TPdf.Active