Adding text that may require more than one page

Hi,
I’m trying to figure out if there is a way to add text that might overflow to the next page using the TextBuilder and TextParagraph classes. Or if there is another way to do this which still gives some control over the rest of the document.

Currently, my text just falls off the page. I’ve tried using the measurement of the paragraph to see when this happens, but as I cannot undo an ‘AppendLine’, I cannot do anything with the knowledge of the overflow.

I’ve found a way to do this: Using TextFragments and adding them to the Paragraphs collection of the PDF Document. Is this the right way to go?

@Drak

Thank you for contacting support.

That is right. New pages will be added automatically if text overflows. Please feel free to contact us if you need any further assistance.

I’m having the same problem, and I don’t see a Paragraphs collection on the PdfDocument object. Can you please post some sample code to show how this should be done?

@bshemmeld

The Paragraphs Collection can be accessed from Page Class in Document object like below:

Document document = new Document();
var page = document.Pages.Add();
var textFragment = new TextFragment($"This test Text")
page.Paragraphs.Add(textFragment);