Text Area

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF Generator for .NET (v4)  /  Re: Text Area

DynamicPDF Generator for .NET (v4) Forum

 Nov 08 2019 8:39 AM
Hi,
I am using the TextArea in a manner such as below:

var headingText = new TextArea(HeadingText, marginX, marginY, page.Dimensions.Width - marginX, 10, HeadingTextFont, HeadingTextPoints, HeadingTextColor);

In the parameter list, I have a “10” value hard coded in for the “float height” parameter. The problem is, I need the value to be dynamic based on the height that is produced by the text itself, not a predefined height.  Because if the text is very short, it creates an unwanted gap.   How can I do this ?

Thanks

Jim
 Nov 08 2019 9:43 AM
Posted by a ceTe Software moderator
Hello,

Yes, you can set the required height to the TextArea to fit the dynamic text without any problem using DynamicPDF Generator. You will need to get the required height to the fit the text using the GetRequiredHeight method and  then set it for the TextArea’s height.

           TextArea headingText = new TextArea(HeadingText, marginX, marginY, page.Dimensions.Width - marginX, 10, HeadingTextFont, HeadingTextPoints, HeadingTextColor);
            //setting required height to fit the dynamic text.
            headingText.Height = headingText.GetRequiredHeight();
          
Thanks,
ceTe Software Support Team
 Nov 08 2019 11:25 AM
Thank you

All times are US Eastern Standard time. The time now is 6:44 PM.