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

Pdf: add text with word wrapping - and return new height

Thread ID:





146707 Aug 14,2019 09:36 PM UTC Aug 15,2019 09:19 AM UTC Xamarin.Forms 2
Tags: PDF
Malcolm Jack
Asked On August 14, 2019 09:36 PM UTC

Is it possible to generate a string in a pdf, that will wrap at a specific width, but continue to grow height, and then return the height, or y bottom coordinate of the result.

Currently - I see you can word wrap with a specific Rect:
PdfStringFormat format = new PdfStringFormat
WordWrap = PdfWordWrapType.Word
var rect = new RectangleF(x, y, maxWidth.Value, 100);
CurrentPageGraphics.DrawString(text, font, brush, rect, format);

... but here, 100 is the height. I'm looking for something along the lines of a PdfLayoutResult after wrapping text that is limited only by width, and not by height.

Malcolm Jack
Replied On August 15, 2019 06:17 AM UTC

I think I have what I'm looking for:

        PdfTextElement element = new PdfTextElement(text, font, brush);
PdfStringFormat format = new PdfStringFormat
WordWrap = PdfWordWrapType.Word
element.StringFormat = format;
RectangleF bounds = new RectangleF(x, y, maxWidth, maxHeight);
result = element.Draw(CurrentPage, bounds);

Prakash Viswanathan [Syncfusion]
Replied On August 15, 2019 09:19 AM UTC

Hi Malcolm, 

Thank you for contacting Syncfusion support.  

Yes it is possible to draw the text to PDF page and get the rendered layout result using PdfLayoutResult class. Please refer below link for more information about rendering text with specified bounds and getting a rendered result (Bounds).  

Please let us know if you need any  further assistance on this.  

Prakash V 


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

This page will automatically be redirected to the 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

Live Chat Icon For mobile
Live Chat Icon