THotPDF.RegisterAcroFormFont

THotPDF AcroForm /DR multi-font registration (v2.119.42)

 

AddXFAPacket  AcroForm 支援  SetFormUnicodeFontDict

註冊額外的 Unicode (Type 0 / CID-keyed) font,以納入 AcroForm Default Resources (/DR) dictionary。這可讓單一 PDF document 同時向 AcroForm widgets 暴露多個 Unicode fonts,通常用於需要同一表單內同時具有 Latin font、CJK font 與 Arabic font 的多語表單

 

Delphi 語法:

FontResourceName - appearance stream /Tf operator 參照的 PDF Name。慣例:使用沒有 leading slash 的短且穩定 identifier(例如 'NotoSansArab'、'NotoSansCJK')。HotPDF 在序列化時會寫入 leading slash

  FontIndirectRef: THPDFObject);

 

說明

AcroForm widgets 會透過 AcroForm dict 上的 Default Resources (/DR) dictionary 參照 fonts,此 dictionary 是所有 form-field appearance streams 的共用 resource pool。v2.119.42 之前,AcroForm /DR 只暴露一個 Unicode font(通常是透過 SetFormUnicodeFontDict 註冊的 helper-set Type 0 font),這會限制多語表單工作流程,因為每個 widget 都必須透過同一個 font program 轉譯

 

v2.119.42 之後,呼叫端可用任意 resource names 註冊額外 Unicode fonts。每個 registered font 會在 EndDoc 時成為 AcroForm /DR dict 內的 /DR /Font /<name> <indirect ref> entry。Widget appearance streams 之後可透過 appearance content stream 內自己的 /Tf <name> <size> operator 參照任何已註冊 name

 

Parameters

FontResourceName - appearance stream /Tf operator 參照的 PDF Name。慣例:使用沒有 leading slash 的短且穩定 identifier(例如 'NotoSansArab'、'NotoSansCJK')。HotPDF 在序列化時會寫入 leading slash

FontIndirectRef - an existing indirect Type 0 (CID-keyed) font dictionary, typically the result of CreateIndirectFontDict over a font registered via RegisterUnicodeTTF.

 

Typical workflow (multilingual form)

 

PDF.RegisterUnicodeTTF('NotoSansArab', 'NotoSansArabic-Regular.ttf');

PDF.RegisterUnicodeTTF('NotoSansJP'  , 'NotoSansJP-Regular.otf');

ArabRef := PDF.CreateIndirectFontDict('NotoSansArab');

JPRef   := PDF.CreateIndirectFontDict('NotoSansJP');

PDF.RegisterAcroFormFont('NotoSansArab', ArabRef);

PDF.RegisterAcroFormFont('NotoSansJP'  , JPRef);

 

現在 Arabic-content widgets 可使用 /NotoSansArab 12 Tf 建立其 appearance streams,而 Japanese-content widgets 可使用 /NotoSansJP 12 Tf,並共用一個 document-wide AcroForm /DR resource pool

 

Coexistence with SetFormUnicodeFontDict

既有 single-font helper(SetFormUnicodeFontDict)仍可供只需要 AcroForm /DR 中一個 Unicode font 的專案使用。RegisterAcroFormFont 是 additive:呼叫端可搭配 SetFormUnicodeFontDict 使用,或在需要多個 Unicode fonts 時完全取代 SetFormUnicodeFontDict

 

請參閱: THotPDF.SetFormUnicodeFontDict, THotPDF.CreateIndirectFontDict, AcroForm 支援, THPDFPage.AddTextField