We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to draw different font style in the same line of PDF in WinRT?

Platform: WinForms |
Control: PDF |
Published Date: January 5, 2016 |
Last Revised Date: January 24, 2020

The PdfTextElement class can be used to draw the text using different font styles in the same line, by getting the bounds of the preceding text. Please find the sample and code snippet below.


float nextText = 0;
private void Button_Click(object sender, RoutedEventArgs e)
//Creates a new pdf document
PdfDocument doc = new PdfDocument();
//Add a page
PdfPage page = doc.Pages.Add();
//Create Pdf graphics for the page
PdfGraphics g = page.Graphics;
PdfBrush brush = PdfBrushes.Black;
PdfFont boldFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12, PdfFontStyle.Bold);
PdfFont regularFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12, PdfFontStyle.Regular);
PdfFont italicFont = new PdfStandardFont(PdfFontFamily.TimesRoman, 12, PdfFontStyle.Italic);
PdfLayoutResult result;
result = AddString("Hello World ", page, 0, brush, boldFont);
result = AddString("Hello World ", page, result.Bounds.Width, brush, regularFont);
result = AddString("Hello World ", page, result.Bounds.Width, brush, italicFont);
private PdfLayoutResult AddString(string note, PdfPage newPage, float xPosition, PdfBrush brush, PdfFont font)
float SpacValue = 10.0f;
nextText = nextText + (xPosition + SpacValue);
//Rendering Text
PdfTextElement richTextElement = new PdfTextElement(note, font, brush);
//Draws String
PdfLayoutResult result = richTextElement.Draw(newPage, new RectangleF(nextText, 0, 0, 0));
return result;


Sample Link:



2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile