Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Tue Sep 13, 2022 12:33 pm

Hi,

Can you please tell me a way through i could make the following text bold as well please tell how to underline and make it italic ?

Code: Select all
  headerText = $"--------------------------------------";
  size = font.MeasureString(headerText);
  doc.Pages[i].Canvas.DrawString(headerText, font, PdfBrushes.Black, doc.Pages[i].Size.Width - 25 - size.Width, 50);


Thanks

haidersoft10P
 
Posts: 6
Joined: Wed Aug 03, 2022 12:05 pm

Wed Sep 14, 2022 8:57 am

Hello haidersoft10P,

Thanks for your inquiry.
You can refer to my code below to complete your requirements, if there is any other problems, please feel free to contact us.
Code: Select all
            PdfDocument pdf = new PdfDocument();
            PdfPageBase page = pdf.Pages.Add();
            PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Times New Roman", 12f, FontStyle.Bold|FontStyle.Italic|FontStyle.Underline));
            PdfSolidBrush brush = new PdfSolidBrush(Color.Blue);
            page.Canvas.DrawString("Hello", font, brush, new PointF(10, 10));
            pdf.SaveToFile("Result.pdf", FileFormat.PDF);


Sincerely,
Simple
E-iceblue support team
User avatar

Simple.Li
 
Posts: 248
Joined: Fri Jul 01, 2022 2:33 am

Return to Spire.PDF