Free Support Forum - aspose.com

TextParagraph text overriden

Hi,


If text goes more than one page, it overrides the content in that same page rather than adding another page. How can I change it so that pages are added dynamically as needed?

Below is my sample code. The output had one pdf page added showing numbers from 160 through 199 (instead of showing 0 through 199)

Document pdfDocument = new Document(@“C:\test.pdf”);
var pdfPage = pdfDocument.Pages.Add();

TextBuilder textBuilder = new TextBuilder(pdfPage);

TextFragment textFragment = new TextFragment(“some text”);
textBuilder.AppendText(textFragment);

TextParagraph paragraph = new TextParagraph();
for (int i = 0; i < 200; i++)
{
paragraph.AppendLine(i+" :\r\n");
}
textBuilder.AppendParagraph(paragraph);

MemoryStream stream = new MemoryStream();
pdfDocument.Save(stream, SaveFormat.Pdf);

return stream;


I am using Aspose.pdf version 9.9.0.0

Thanks !!!

Hi John,

Thanks for your inquiry. I have tested your scenario using Aspose.Pdf for .NET 10.5.0 and managed to observe the reported issue. For further investigation, I have logged an issue in our issue tracking system as PDFNEWNET-39038 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

Please feel free to contact us for any further assistance.

<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif”;mso-fareast-font-family:
Calibri;color:#333333;mso-ansi-language:EN-US;mso-fareast-language:EN-US;
mso-bidi-language:AR-SA”>Best Regards

Thank you. In the meanwhile, is there an alternate way of achieving the same?

Hi John,


Thanks for your inquiry. Please check following code sample, hopefully it will help you to accomplish the task.

Document pdfDocument = new Document();<o:p></o:p>

var pdfPage = pdfDocument.Pages.Add();

pdfPage.Paragraphs.Add(new TextFragment("text"));

TextFragment textFragment = new TextFragment("some text");

pdfPage.Paragraphs.Add(textFragment);

for (int i = 0; i < 200; i++)

{

pdfPage.Paragraphs.Add(new TextFragment(i + " :\r\n"));

}

pdfDocument.Save(myDir+"Textoutput.pdf");

Please feel free to contact us for any further assistance.


Best Regards,