We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to get positioned TextFragment to overflow to new page?

I am trying to write some variable length text to a PDF page that I need to be able to position and have overflow to a new page if the text extends passed the bottom of the current page.

I tried using TextParagraph and TextFragment with TextBuilder but I have not been able to successfully get the text to overflow to a new page. If I set the Position property of TextParagraph or TextFragment, it will write all of the text on the same page with no overflow. If I position the text by setting the Rectangle property, it truncates the text wherever the rectangle ends.

Is there a built in way or a workaround that I can use to position the text and have it overflow to a new page if necessary?


To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input PDF document.
  • Please attach the output PDF file that shows the undesired behavior.
  • Please attach the expected output PDF file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


Thanks for your response.

Here is the information as requested PageOverflowSample.zip (349.5 KB)

Please note that the source code and files are just a simple example of what I am trying to accomplish for my specific use case. If you have any questions, let me know.


Please use TextFragment as shown below to get the desired output. Hope this helps you.

Document pdfDocument = new Document(inputFilePath);
Aspose.Pdf.Text.TextFragment text = new Aspose.Pdf.Text.TextFragment("A quick brown fox jumped over the lazy dog. A quick brown fox jumped over the lazy dog. A quick brown fox jumped over the lazy dog. A quick brown fox jumped over the lazy dog. A quick brown fox jumped over the lazy dog. A quick brown fox jumped over the lazy dog. A quick brown fox jumped over the lazy dog. A quick brown fox jumped over the lazy dog.");
text.Position = new Position(20, 10);
text.TextState.FormattingOptions = new Aspose.Pdf.Text.TextFormattingOptions()
SubsequentLinesIndent = 20
Aspose.Pdf.Page page = pdfDocument.Pages[1];

string outputPath = usePosition ? positionParagraphOutput : rectangleParagraphOutput;


I ran a test using code similar to your solution above. I was able to get the text to position correctly and overflow to a new page.

However, I’m getting a strange behavior where several blank pages are being inserted into the document between the first page and where the text I am adding programmatically is being placed. I’m not sure if this is something I am doing incorrectly or if it is a bug.

Here are some updated examples and source code for you to reference. PageOverflowSample_12_7.zip (236.8 KB)


We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51027. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.