/Title 項目的值property Title: WString; // read only
Title 會回傳文件宣告的標題,也就是 Acrobat 在應用程式標題列顯示的同一串文字,只要開啟 "Display document title in title bar" viewer preference 就會看到
這個值是透過 MetaText['Title'] 取得,內部會呼叫 PDFium 的 FPDF_GetMetaText 去讀文件資訊字典中的 /Title 項目(ISO 32000-1 § 14.3.3)
如果該項目不存在,或元件目前沒有啟用,這個屬性就會回傳空的 WString,它刻意和檔名基底不同,例如剛輸出的 quarterly-2026.pdf,仍然可以透過 /Title 宣告自己是 "Q1 2026 Financial Review"
這個屬性是唯讀,若要在建立時就寫入標題,請透過 FPDF_SetMetaText 搭配 Document handle,或直接寫入 XMP 中繼資料串流(dc:title)
True,但即使未啟用,這個屬性也能安全呼叫,只是會回傳空字串WString 不會因為產生器不同而解碼錯誤/Title 和 XMP 的 dc:title 兩邊一致,若要產生 PDF/A 文件,請同時更新兩個面向,並在 round-trip 之後再驗證一次Title = '' 時可以把它視為未命名,UI 再回退到檔名
function EffectiveTitle(Pdf1: TPdf; const Fallback: string): string;
begin
if not Pdf1.Active then
Pdf1.Active := True;
Result := Trim(Pdf1.Title);
if Result = '' then
Result := Fallback;
end;
// Use the document's own title for the form caption.
Caption := EffectiveTitle(Pdf1, ExtractFileName(Pdf1.FileName));