PDFiumPas 文件

Author 屬性

此 API 條目保留識別符號、簽名、程式碼塊和 PDF 術語的原始形式
元件: TPdf  ·  單元: PDFium
傳回 PDF 文件資訊字典中 /Author 項目的值

語法

property Author: WString; // read only

說明

Author 會傳回撰寫原始文件之人員或組織的可讀名稱。內部來說,這個屬性只是 MetaText['Author'] 的薄包裝,而後者又會呼叫 PDFium 的 FPDF_GetMetaText,讀取文件資訊字典中的 /Author 字串(該字典由尾碼的 /Info 鍵所參照 — 請參見 ISO 32000-1 第 14.3.3 節 "Document Information Dictionary")

如果文件沒有宣告作者,或文件目前尚未載入,結果會是空的 WString。這個屬性不會丟出例外 — 空字串才是「沒有記錄作者」的正確哨兵值。由於底層 PDFium API 會替你把原始 PDFDocEncodingUTF-16BE 位元組字串解碼成 UTF-16,因此結果一律會以 Delphi 原生的 WideString 編碼傳回,並可安全地直接指定給 TStringsTLabel 或任何其他支援 Unicode 的介面

此屬性為唯讀。若要在新建立或已載入的文件上設定作者,請直接對 Document 控制代碼使用較低階的 FPDF_SetMetaText 匯入,或透過中繼資料串流撰寫/重新整理 XMP 封包

備註

範例

procedure TForm1.ShowDocumentInfo;
begin
  Pdf1.FileName := 'C:\Docs\Report.pdf';
  Pdf1.Active := True;
  try
    Memo1.Lines.Add('Title: ' + Pdf1.Title);
    Memo1.Lines.Add('Author: ' + Pdf1.Author);
    Memo1.Lines.Add('Subject: ' + Pdf1.Subject);
    if Pdf1.Author = '' then
      Memo1.Lines.Add(' (no /Author entry in info dictionary)');
  finally
    Pdf1.Active := False;
  end;
end;

另請參閱

Title, Subject, Creator, Producer, Keywords, MetaText, CreationDate, ModifiedDate