I have code that is building a PDF document from a series of FormattedTextArea elements. In some cases, I do not want to break a paragraph across a page, but rather would like to keep it whole, intact. So I have code that calls the GetRequiredHeight() method and compares it to how much space I have left on the page (I am keeping track of the Y coordinate as I add text areas...).
If the Required Height is more than I have space for, I added code to set that FormattedTextArea element to 0 (zero). It gets passed up to a calling method that essentially does the following (psuedo code)
// squash it down so it shouldn't have space to draw any text?
myTextArea.Height = 0;
// now, place what I think is a zero height element
page.Elements.Add (myTextArea)
// get overflow text, which I was expecting now to be the entire text of the element, since none of it should have been placed in the previous statement
FormattedTextArea overflowText = thatTextArea.GetOverFlowTextArea();
// add a new page..
// on new page, place the overflowText element
But what I am finding is that the first line of the original FormattedTextArea element is always drawn on the first page, then the rest of the text is dutifully drawn to the next page...
How can I keep the entire FormattedTextArea element together?
PageElement height set to 0, but still writes to page
Re: PageElement height set to 0, but still writes to page
Support · Jun 4, 2020Hi,
A FormattedTextArea will always output at least one line of text. This is expected behavior.
Try adding it to the appropriate page based on the RequiredHeight (instead of setting the height to 0 after adding it).
Thanks,
ceTe Software Support Team