ImageEn, unit iexPdfiumCore

TPdfObject.SetTextFont

TPdfObject.SetTextFont

Declaration

function SetTextFont(FontSize: Single): Boolean; overload;
function SetTextFont(FontSize: Single; FontColor: TRGBA): Boolean; overload;
function SetTextFont(FontSize: Single; FontColor: TColor): Boolean; overload;

Description

Changes the font size and color of a text object (when ObjectType is ptText).
FontSize is specified in points. Pass 0 to change only the color.
When FontColor is a TColor, the current opacity of the text is kept.
Returns False if the object is not a text object, or the size could not be set.

Note:
◼The font name and style of existing text cannot be changed. To use a different font, delete the object and recreate it using AddText
◼The size is applied to the font, so it is still scaled by the object's matrix
◼Use GetTextFont to read the current font properties
◼Changes to the page are only saved after calling ApplyChanges

Example

// Make the selected text object 18pt and red
ImageEnView1.PdfViewer.Objects[idx].SetTextFont( 18, clRed );
ImageEnView1.PdfViewer.ApplyChanges();

// Double the size of all text in the current page
for i := 0 to ImageEnView1.PdfViewer.Objects.Count - 1 do
  if ImageEnView1.PdfViewer.Objects[i].ObjectType = ptText then
  begin
    ImageEnView1.PdfViewer.Objects[i].GetTextFont( fontName, fontSize, fontColor, fontStyle );
    ImageEnView1.PdfViewer.Objects[i].SetTextFont( fontSize * 2 );
  end;
ImageEnView1.PdfViewer.ApplyChanges();

See Also

◼FillColor
◼GetTextFont
◼Text
◼AddText