ImageEn, unit iexPdfiumCore

TPdfObjectList.AddText

TPdfObjectList.AddText


Declaration

function AddText(X, Y: Single; const Text: string; FontName: string; FontSize: Single; FontStyle: TFontStyles = []; Rotation: Single = 0): TPdfObject; overload;
function AddText(X, Y: Single; const Text: String; Font: TFont; Rotation: Single = 0): TPdfObject; overload;


Description

Add 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: You must call ApplyChanges before saving to apply object changes to the document


PDF Page Points

Objects on a PDF page are specified in points that originate at the bottom-left, i.e. when X,Y = (0,0). The top-left of the page is specified by (PageWidth, PageHeight).
To convert PDF points to screen values, use PageToScr.



Standard Font Example

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

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

// 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 ));


Embedded Font File Example

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