THotPDF.RegisterAcroFormFont

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

 

AddXFAPacket  AcroForm Support  SetFormUnicodeFontDict

AcroForm Default Resources(/DR) dictionary에 포함할 추가 Unicode(Type 0 / CID-keyed) font를 등록합니다. 단일 PDF document가 여러 Unicode font를 AcroForm widget에 동시에 노출할 수 있게 하며, 일반적으로 같은 form 안에 Latin font, CJK font, Arabic font 등이 함께 필요한 multilingual form에 사용됩니다

 

Delphi 구문:

procedure RegisterAcroFormFont(const FontResourceName: AnsiString;

  FontIndirectRef: THPDFObject);

 

설명

AcroForm widget은 AcroForm dict의 Default Resources(/DR) dictionary를 통해 font를 참조하며, 이는 모든 form-field appearance stream을 위한 shared resource pool 역할을 합니다. v2.119.42 이전의 AcroForm /DR은 정확히 하나의 Unicode font(일반적으로 SetFormUnicodeFontDict로 등록된 helper-set Type 0 font)만 노출했으므로 모든 widget이 같은 font program으로 렌더링되어야 해 multilingual form workflow가 제한되었습니다

 

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 - appearance stream /Tf operator가 참조하는 PDF Name입니다. Convention은 leading slash가 없는 짧고 안정적인 identifier입니다(예: 'NotoSansArab', 'NotoSansCJK'). HotPDF는 serialize할 때 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 widget은 /NotoSansArab 12 Tf로 appearance stream을 작성하고 Japanese-content widget은 /NotoSansJP 12 Tf를 사용하면서, 하나의 document-wide AcroForm /DR resource pool을 공유할 수 있습니다

 

Coexistence with SetFormUnicodeFontDict

기존 single-font helper(SetFormUnicodeFontDict)는 AcroForm /DR에 Unicode font 하나만 필요한 project에서 계속 동작합니다. RegisterAcroFormFont는 additive입니다. 호출자는 SetFormUnicodeFontDict와 함께 사용할 수도 있고, 둘 이상의 Unicode font가 필요할 때 SetFormUnicodeFontDict를 완전히 대체할 수도 있습니다

 

참조: THotPDF.SetFormUnicodeFontDict, THotPDF.CreateIndirectFontDict, AcroForm Support, THPDFPage.AddTextField