|
PDF 1.5+ AcroForm rich-text text widget(ISO 32000-1 12.7.4.3 + Annex L)을 current page에 추가합니다. Widget은 rich text를 parse하지 않는 reader가 사용하는 standard /V + /DV plain-text fallback과, Acrobat 및 Foxit이 styled text rendering에 직접 사용하는 새 /RV rich-text XHTML body 및 /DS default style entry를 포함합니다. /Ff RichText bit(26)는 자동으로 OR됩니다
Delphi 구문:
procedure AddRichTextField(const FieldName, InitialValue: AnsiString; const RichValue, DefaultStyle: AnsiString; Rectangle: TRect; MaxLen: Integer = 0; Flags: THPDFFormFieldFlags = []);
C++ 구문:
void AddRichTextField(const AnsiString& FieldName, const AnsiString& InitialValue, const AnsiString& RichValue, const AnsiString& DefaultStyle, const TRect& Rectangle, int MaxLen = 0, THPDFFormFieldFlags Flags = THPDFFormFieldFlags());
설명
Widget은 /FT /Tx, /DA (/Helv 12 Tf 0 0 0 rg), RichText bit가 설정된 /Ff, 제공된 InitialValue를 /V 및 /DV로, RichValue를 /RV로, DefaultStyle을 /DS로 가진 Tx form field로 emit됩니다. InitialValue, RichValue, DefaultStyle은 multi-byte content를 자동 감지하고 필요할 때 UTF-16BE hex-string encoding으로 전환합니다(international plain-text field에 대한 기존 AddTextField behavior와 일치)
Rich-text rendering은 reader에서 일어납니다. Acrobat / Foxit / Edge / Chrome PDF viewer는 RichText bit가 켜져 있을 때 모두 /RV를 parse하고 system의 Unicode font fallback을 가져오므로, HotPDF가 /DR Resources에 CID font를 embed하지 않아도 CJK, Cyrillic, Arabic, accented Latin content가 올바르게 표시됩니다. HotPDF 자체 AutoFormAppearances path에서는 multi-byte text를 위한 placeholder empty-AP branch가 그대로 유지됩니다(v2.56.0+ task). Rich-text-aware reader는 해당 AP를 무시하고 /RV에서 직접 렌더링합니다
FieldName - PDF form field의 /T partial name입니다(parent 안에서 unique해야 함). Space와 non-ASCII byte를 허용하며, non-ASCII는 emit되는 /T string에서 UTF-16BE encoding을 trigger합니다
InitialValue - /V 및 /DV에 쓰이는 plain-text PDF text string입니다. /RV를 parse하지 않는 reader는 display를 위해 이 값으로 fallback합니다
RichValue - PDF 1.7 Annex L tagged XHTML body (the most portable form starts with <?xml version="1.0"?> and an XHTML <body> root carrying the xfa:contentType="text/html" namespace attribute). Inline styling uses <span style="..."> with CSS properties (font-family, font-size, font-weight, font-style, color, etc.).
DefaultStyle - CSS-like style string applied to characters the user types at fill time when no per-character style is present in /RV. Example: 'font: 12pt Helvetica; color: #000000'.
Rectangle - HotPDF screen coordinate(top-left origin)의 widget /Rect입니다. Rect가 PDF user space로 변환될 때 YProjection은 자동으로 일어납니다
MaxLen - optional; when greater than zero, emits a /MaxLen entry capping the user-entered character count. Defaults to 0 (no limit).
Flags - optional입니다. Auto-added RichText bit 외에 /Ff로 OR할 extra field flag입니다. Typical extra flag는 multi-paragraph rich-text body용 ffMultiline, display-only formatted text용 ffReadOnly입니다. ffRichText flag는 항상 추가되므로 호출자가 포함할 필요가 없습니다
Code Example
// Rich-text Tx widget with bold + italic markup
var
Rich, DS: AnsiString;
R: TRect;
begin
HPDF.BeginDoc;
Rich :=
'<?xml version="1.0"?>' +
'<body xmlns="http://www.w3.org/1999/xhtml" ' +
'xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" ' +
'xfa:contentType="text/html">' +
'<p style="font-family:Helvetica;font-size:12pt">' +
'<span style="font-weight:bold">Bold</span> and ' +
'<span style="font-style:italic">italic</span> text.' +
'</p></body>';
DS := 'font: 12pt Helvetica; color: #000000';
R.Left := 60; R.Top := 60; R.Right := 280; R.Bottom := 100;
HPDF.CurrentPage.AddRichTextField(
'Biography', 'Plain biography text', Rich, DS, R);
HPDF.EndDoc;
end;
See Also
AddTextField, AutoFormAppearances, Version, AcroForm Support
|