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
close icon

How to determine the length of an element?

Hi, I am new user to SyncFusion. I am trying to understand how to determine where the next content should be placed. For example I have some text and use the Graphics.DrawString to write it out. then i need to put a table in after the text. My question is how do I get where the text ended so that I can use those coordinates to start my table at.

1 Reply

PH Praveenkumar H Syncfusion Team May 22, 2013 04:14 AM UTC

Hi Neelima,

Thank you for using Syncfusion products,

We can get the bounds of the drawn text as follow.

  PdfFont font = new PdfTrueTypeFont(new Font("arial", 12));
  PdfTextElement element = new PdfTextElement("Hi Hellow World", font);

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

   // Set the layout format properties to make the text flow through multiple pages.
   PdfLayoutFormat layoutFormat = new PdfLayoutFormat();
   layoutFormat.Break = PdfLayoutBreakType.FitPage;
   layoutFormat.Layout = PdfLayoutType.Paginate;

  // Set the bounds.
  RectangleF bounds = new RectangleF(PointF.Empty, page.Graphics.ClientSize);

   // Draw the text element.
  PdfTextLayoutResult result= element.Draw(page, bounds, layoutFormat)

 Here "result" gives the bounds of the text.

 Please follow the below link for more information about the PdfTextElement.

Please let us know if you have any concern,

With Regards,

Live Chat Icon For mobile
Up arrow icon