Text on PDF questions

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

DynamicPDF Generator for .NET (v4) Forum

 Oct 25 2019 5:07 PM
Question 1:
With the below code to put text in a PDF…..
var headingText = new Label(HeadingText, MarginX, MarginY, page.Dimensions.Width - MarginX, 20, HeadingTextFont, HeadingTextPoints, HeadingTextColor);

I have the hard coded 20 for “Height”.  Is there anyway for this value to be dynamic based on the amount of text? If not, how can I calculate “height” that is based on only what is needed for the text? 

Question 2:
Is there anyway to detect if text will run off the side or bottom of the document (or not) due to the fact the page is not long or wide enough ?

Thanks
 Oct 28 2019 10:11 AM
Posted by a ceTe Software moderator
Hello,

The Label page element is designed to display a limited amount of text. If you have multiple lines of text or want to overflow text to other pages or to a different location on a page, the TextArea page element is more appropriate.

To get the height required to display the text in a TextArea, use the TextArea’s GetRequiredHeight method. Please refer to the TextContinuation topic and the TextArea members in our help documentation for more information.

However, if you need to use the Label element, you can use the Font class to calculate the line-height. You can go through the Font class members to calculate the height of a line using the ascender, descender values. You can also get the width required by the text using the GeTextWidth method.

Thanks,
ceTe Software Support Team.

All times are US Eastern Standard time. The time now is 4:43 AM.