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.
Unfortunately, activation email could not send to your email. Please try again.

Determine string width

Thread ID:





94852 Jun 4,2010 05:05 PM Jun 8,2010 05:23 AM ASP.NET Web Forms (Classic) 1
Tags: PDF
Asked On June 4, 2010 05:05 PM


Once I draw a string onto a pdf page. is it possible to determine the width of the string?

I want to use this information to align the string betwee two other objects.

Thank you

Sundaram R [Syncfusion]
Replied On June 8, 2010 05:23 AM

Hi Theo,

Thanks for using Syncfusion products.

You can use the type PdfTextElement to retrieve the width of the rendered string. Please find the code snippet below to do the same,

PdfDocument pdfDoc = new PdfDocument();

PdfPage page = pdfDoc.Pages.Add();

// Create a text element with text.
PdfTextElement element = new PdfTextElement("Test string", new PdfStandardFont(PdfFontFamily.TimesRoman, 2));

// Set the properties for the text element.
element.Brush = new PdfSolidBrush(System.Drawing.Color.Black);

// Draw the text element and store its layout information
PdfLayoutResult layoutResult = element.Draw(page, new PointF(5,5));

//Retrieve the rendered width of the text
float width = layoutResult.Bounds.Width;

Also for reference go through the content in the following URL,


If you have any further queries, please contact us.

Sundaram R.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

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.