THotPDF.RegisterAcroFormFont

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

 

AddXFAPacket  AcroForm Support  SetFormUnicodeFontDict

Регистрирует дополнительный Unicode (Type 0 / CID-keyed) font для включения в AcroForm Default Resources (/DR) dictionary. Это позволяет одному PDF document одновременно предоставлять AcroForm widgets несколько Unicode fonts, что обычно нужно для multilingual forms с Latin font, CJK font и Arabic font в одной форме

 

Delphi syntax:

procedure RegisterAcroFormFont(const FontResourceName: AnsiString;

  FontIndirectRef: THPDFObject);

 

Описание

AcroForm widgets ссылаются на fonts через Default Resources (/DR) dictionary в AcroForm dict, который является shared resource pool для всех form-field appearance streams. До v2.119.42 AcroForm /DR открывал ровно один Unicode font, обычно helper-set Type 0 font, зарегистрированный через SetFormUnicodeFontDict, что ограничивало multilingual form workflows

 

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.

 

Параметры

FontResourceName — PDF Name, на который ссылается operator /Tf в appearance stream. Convention: короткий стабильный идентификатор без ведущего slash, например 'NotoSansArab' или 'NotoSansCJK'. HotPDF добавляет ведущий slash при serialising

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

 

Теперь widgets с Arabic content могут создавать appearance streams с /NotoSansArab 12 Tf, а widgets с Japanese content — с /NotoSansJP 12 Tf, разделяя один document-wide AcroForm /DR resource pool

 

Coexistence with SetFormUnicodeFontDict

Существующий single-font helper (SetFormUnicodeFontDict) продолжает работать для проектов, которым нужен только один Unicode font в AcroForm /DR. RegisterAcroFormFont является additive: callers могут использовать его вместе с SetFormUnicodeFontDict или полностью заменить SetFormUnicodeFontDict, когда нужен более чем один Unicode font

 

См. также: THotPDF.SetFormUnicodeFontDict, THotPDF.CreateIndirectFontDict, AcroForm Support, THPDFPage.AddTextField