THotPDF.RegisterAcroFormFont

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

 

AddXFAPacket  AcroForm Support  SetFormUnicodeFontDict

Registers an additional Unicode (Type 0 / CID-keyed) font for inclusion in the AcroForm Default Resources (/DR) dictionary. Lets a single PDF document expose multiple Unicode fonts to AcroForm widgets simultaneously - typically used for multilingual forms that need (for example) a Latin font plus a CJK font plus an Arabic font in the same form.

 

Delphi syntax:

procedure RegisterAcroFormFont(const FontResourceName: AnsiString;

  FontIndirectRef: THPDFObject);

 

Description

AcroForm widgets reference fonts through a Default Resources (/DR) dictionary on the AcroForm dict, which acts as the shared resource pool for all form-field appearance streams. Pre-v2.119.42 the AcroForm /DR exposed exactly one Unicode font (typically the helper-set Type 0 font registered through SetFormUnicodeFontDict), which constrained multilingual form workflows because every widget had to render through the same font program.

 

After v2.119.42 callers can register additional Unicode fonts at arbitrary resource names. Each registered font becomes a /DR /Font /<name> <indirect ref> entry inside the AcroForm /DR dict at EndDoc. Widget appearance streams can then reference any of the registered names through their own /Tf <name> <size> operator inside the appearance content stream.

 

Parameters

FontResourceName - the PDF Name that the appearance stream /Tf operator references. Convention: a short stable identifier without leading slash (e.g. 'NotoSansArab', 'NotoSansCJK'). HotPDF writes the leading slash when serializing.

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

 

Now Arabic-content widgets can author their appearance streams with /NotoSansArab 12 Tf while Japanese-content widgets use /NotoSansJP 12 Tf, sharing one document-wide AcroForm /DR resource pool.

 

Coexistence with SetFormUnicodeFontDict

The pre-existing single-font helper (SetFormUnicodeFontDict) continues to work for projects that only need one Unicode font in the AcroForm /DR. RegisterAcroFormFont is additive: callers can use it in addition to SetFormUnicodeFontDict, or replace SetFormUnicodeFontDict entirely when more than one Unicode font is needed.

 

See also: THotPDF.SetFormUnicodeFontDict, THotPDF.CreateIndirectFontDict, AcroForm Support, THPDFPage.AddTextField