How to add text to pdf with given fontsize,fontname and fontcolor?

Hi,Support:

How to add text to pdf with given fontsize,fontname and fontcolor?

            Dim Frg = New Global.Aspose.Pdf.Text.TextFragment(AddText)
            Frg.Margin.Left = NPdfTextX.Value / 100 * Pw - Pl
            Frg.Margin.Top = NPdfTextY.Value / 100 * Ph - PT
            Frg.TextState.FontSize = NPdfAddTextSize.Value
                             Frg.TextState.ForegroundColor = Global.Aspose.Pdf.Color.FromRgb(BCmdTextColor.BackColor.R, BCmdTextColor.BackColor.G, BCmdTextColor.BackColor.B)

Frg.TextState.Font = New Global.Aspose.Pdf.Text.Font() 'this show it is readonly so that setting fontname to it is not banned.

How to set fontname to the added text?

            Pdf.Pages(p).Paragraphs.Add(Frg)

@ducaisoft

Please use following line to set the font:

Frg.TextState.Font = FontRepository.FindFont("Arial")

Thanks.
I have gotten demo from other topic like this code.

1 Like