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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Determine string width

Thread ID:





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


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 09:23 AM UTC

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.

Please sign in to access our forum

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

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