PDFium Delphi Component 文件

AnnotationCount 屬性

元件: TPdf  ·  單元: PDFium
目前作用中頁面所附加的註解物件數量

Syntax

property AnnotationCount: Integer; // read only

Description

AnnotationCount 傳回目前頁面 /Annots 陣列的長度(PDF 1.7 規格第 12.5 節)。所有註解子類型都會計入 — 文字備註、醒目提示、底線、自由文字、筆跡、印章、多邊形與折線形狀、連結註解、彈出對話方塊,以及表單 widget 註解。將每一頁的值相加,即可得到整份文件的註解總數

此屬性要求 Active 為 True,並從 PageNumber 指定的頁面讀取。當頁面沒有註解或文件未載入時,值為 0。使用 Annotation[Index] 搭配 0 到 AnnotationCount - 1 的索引,可取得 TPdfAnnotation 記錄,其中描述每個項目的子類型、週框矩形、顏色、旗標位元遮罩與內容文字

列舉註解的複雜度為 O(n),且每次 Annotation[Index] 呼叫都會開啟新的 PDFium 控制代碼並視需要解碼 Unicode 內容;若需多次使用結果,請加以快取。變更頁面的註解(插入、刪除)會使索引失效 — 變更後請重新開始迴圈或重新讀取 AnnotationCount

Remarks

Example

var I: Integer;
var A: TPdfAnnotation;
for I := 0 to Pdf1.AnnotationCount - 1 do
begin
  A := Pdf1.Annotation[I];
  Memo1.Lines.Add(Format('%d: subtype=%d text=%s',
    [I, Ord(A.Subtype), A.ContentsText]));
end;

See Also

Annotation, LinkAnnotationCount, FormFieldCount, PageNumber