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 να εκθέτει πολλαπλές Unicode fonts σε AcroForm widgets ταυτόχρονα - συνήθως για 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, το οποίο λειτουργεί ως κοινό resource pool για όλα τα form-field appearance streams. Πριν από το v2.119.42, το AcroForm /DR εξέθετε ακριβώς μία Unicode font (συνήθως την helper-set Type 0 font που καταχωρείται μέσω SetFormUnicodeFontDict), κάτι που περιόριζε τα multilingual form workflows επειδή κάθε widget έπρεπε να αποδίδεται μέσω του ίδιου 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 - το PDF Name στο οποίο αναφέρεται ο operator /Tf του appearance stream. Σύμβαση: ένα σύντομο σταθερό identifier χωρίς leading slash (π.χ. 'NotoSansArab', 'NotoSansCJK'). Το HotPDF γράφει το leading slash κατά το serialization

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) συνεχίζει να λειτουργεί για projects που χρειάζονται μόνο μία Unicode font στο AcroForm /DR. Το RegisterAcroFormFont είναι additive: οι καλούντες μπορούν να το χρησιμοποιήσουν επιπλέον του SetFormUnicodeFontDict ή να αντικαταστήσουν πλήρως το SetFormUnicodeFontDict όταν χρειάζονται περισσότερες από μία Unicode fonts

 

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