THPDFPage.AddRichTextField Metodo

Il rendering rich-text avviene nel reader: Acrobat / Foxit / Edge / Chrome PDF viewer analizzano tutti /RV quando il bit RichText e attivo e usano fallback font Unicode dal sistema, quindi contenuto CJK, cirillico, arabo e latino accentato viene visualizzato correttamente senza che HotPDF incorpori un font CID in /DR Resources. Per il percorso AutoFormAppearances di HotPDF resta il ramo placeholder empty-AP per testo multi-byte (attivita v2.56.0+); i reader consapevoli di rich-text ignorano tale AP e renderizzano direttamente da /RV

 

FieldName - nome parziale /T del campo modulo PDF (deve essere unico nel suo parent). Spazi e byte non ASCII sono accettati; il non ASCII attiva la codifica UTF-16BE sulla stringa /T emessa

InitialValue - stringa testo PDF in testo semplice scritta in /V e /DV. I reader che non analizzano /RV ripiegano su questo valore per la visualizzazione

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 - /Rect del widget nelle coordinate schermo HotPDF (origine in alto a sinistra); la YProjection avviene automaticamente quando il rettangolo viene convertito nello spazio utente PDF

MaxLen - optional; when greater than zero, emits a /MaxLen entry capping the user-entered character count. Defaults to 0 (no limit).

Flags - opzionale; eventuali flag campo extra da combinare con OR in /Ff oltre al bit RichText aggiunto automaticamente. Flag extra tipici: ffMultiline per corpi rich-text multi-paragrafo, ffReadOnly per testo formattato solo visualizzazione. Il flag ffRichText viene sempre aggiunto, quindi il chiamante non deve includerlo

 

Example di codice

// 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.Inizio := 60; R.Right := 280; R.Bottom := 100;

  HPDF.CurrentPage.AddRichTextField(
    'Biography', 'Plain biography text', Rich, DS, R);

  HPDF.EndDoc;
end;

 

Vedi anche

AddTextField, AutoFormAppearances, Version, Supporto AcroForm