ImageEn, unit iexPdfiumCore

TPdfObjectList.AddText

TPdfObjectList.AddText


Declaration

function AddText(X, Y: Single; const Text: string; FontName: string; FontSize: Single; FontStyle: TFontStyles = [])): TPdfObject;


Description

Adds a text object to the current page at the specified position (in terms of PDF points).

FontName can be one of the standard PDF fonts:
Const Value Alias (Windows Common Name)
Font_Helvetica 'Helvetica' 'Arial'
Font_Courier 'Courier' 'Courier New'
Font_TimesRoman 'Times-Roman' 'Times New Roman'
Font_Symbol 'Symbol' 'Symbol'
Font_ZapfDingbats 'ZapfDingbats' N/A
 If you specify one of these fonts, it does not need to be embedded into the PDF document (i.e. document will be smaller).

Alternatively you can specify a TTF font that is registered with Windows (e.g. 'Impact' or 'Tahoma'), which will be embedded.
Or you can specify the full path to a TTF font, e.g. 'C:\MyFonts\FancyFont.ttf', which will be embedded.

Note: PDF pages are specified Bottom-Up, i.e. Y=0 refers to the bottom of the page/screen. Y=PageHeight refers to the top of the page/screen


Standard Font Example

ImageEnView1.PdfViewer.Objects.AddText( 100, 800, 'ImageEn Rocks!', Font_Helvetica, 20, TColor2TRGBA( clBlue, 255 ), [fsBold] );
ImageEnView1.Invalidate();

// Which is the same as...
ImageEnView1.PdfViewer.Objects.AddText( 100, 800, 'ImageEn Rocks!', Font_Helvetica_Bold, 20, TColor2TRGBA( clBlue, 255 ), [] );
ImageEnView1.Invalidate();

// Which is the same as...
ImageEnView1.PdfViewer.Objects.AddText( 100, 800, 'ImageEn Rocks!', 'Arial', 20, TColor2TRGBA( clBlue, 255 ), [fsBold] );


Embedded Windows Font Example

ImageEnView1.PdfViewer.Objects.AddText( 100, 800, 'ImageEn Rocks!', 'Impact', 20, TColor2TRGBA( clBlue, 255 ));
ImageEnView1.Invalidate();


Embedded Font File Example

ImageEnView1.PdfViewer.Objects.AddText( 100, 800, 'ImageEn Rocks!', 'C:\MyFonts\FancyFont.ttf', 20, TColor2TRGBA( clBlue, 255 ), [fsBold] );
ImageEnView1.Invalidate();