An error occurred while processing paragraphs

Following is the code, and the attached image is error detail.


Page page = document.Pages.Add();
var builder = new StringBuilder();
builder.Append("
");
for (int i = 0; i < 10000; i++)
{
builder.Append(“A”);
}
builder.Append("
");
var html = new HtmlFragment(builder.ToString());
page.Paragraphs.Add(html);

Hi Zaho,


Thanks for your inquiry. I have tested the scenario and noticed the reported issue. So logged a ticket PDFNEWNET-39974 in our issue tracking system for further investigation and resolution. We will notify you as soon as it is resolved.

Meanwhile you can use ProcessParagraphs() method for Document object i.e.

document.ProcessParagraphs();<o:p></o:p>

We are sorry for the inconvenience caused.


Best Regards,

hi,

1. What is the different between document.ProcessParagraghs() and page.ProcessParagraphs()?
2. If I use document.ProcessParagraphs(), the code will remain running and never come to an end.
Best.

zhaochen_81:
1. What is the different between document.ProcessParagraghs() and page.ProcessParagraphs()?
Hi Zaho,

Thanks for contacting support.

When calling ProcessParagraphs(…) method for Document object, all the paragraphs inside whole document are processed whereas when calling ProcessParagraphs(…) on specific page object, only the paragraphs in that document are processed.
zhaochen_81:
2. If I use document.ProcessParagraphs(), the code will remain running and never come to an end.
I have tested the scenario using Aspose.Pdf for .NET 11.0.0 and I am unable to notice any issue. As per my observations, the resultant file is properly being generated. For your reference, I have also attached the document generated over my end.
Hi,

1. Since I only add one page, I think there should be no difference between two methods.
2. That is easy to reproduce this issue, only by increase for index to 20000 or more; Besides, this is a bad user experience since it will process for a very long time. And I want to know that if 20000 characters is a burden to HtmlFragment?

Best.
Hi Zhao,

Thanks for your feedback.

zhaochen_81:

1. Since I only add one page, I think there should be no difference between two methods.


We are sorry for the confusion, ProcessParagraphs() method of Page class is internal method we will mark this private soon. It is recommend to use ProcessParagraphs() method of Document class.
zhaochen_81:

2. That is easy to reproduce this issue, only by increase for index to 20000 or more; Besides, this is a bad user experience since it will process for a very long time. And I want to know that if 20000 characters is a burden to HtmlFragment?


I have tested the scenario using Aspose.Pdf for .NET 11.0.0 on Win7 64 bit with 8GB RAM and unable to replicate the issue. We will appreciate it if you please share some more details to replicate the issue.

Document pdf = new Document();

Aspose.Pdf.Page page = pdf.Pages.Add();

var builder = new StringBuilder();

builder.Append("");

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

{

builder.Append("A");

}

builder.Append("

");

var html = new HtmlFragment(builder.ToString());

page.Paragraphs.Add(html);

pdf.ProcessParagraphs();

pdf.Save(myDir + "HtmlFragmenttest.pdf");

We are sorry for the inconvenience caused.


Best Regards,

Hi Zaho,


Thanks for sharing the details.

Adding more to Tilal’s comments, I have also tested the scenario while using 20000 as iteration value and I am unable to notice any issue. As per my observations, the process is completing in 6 seconds.

[C#]

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

Page page = document.Pages.Add();<o:p></o:p>

var builder = new StringBuilder();<o:p></o:p>

builder.Append("

");<o:p></o:p>

for (int i = 0; i < 20000; i++)<o:p></o:p>

{<o:p></o:p>

builder.Append(“A”);<o:p></o:p>

}<o:p></o:p>

builder.Append("

");<o:p></o:p>

var html = new HtmlFragment(builder.ToString());<o:p></o:p>

page.Paragraphs.Add(html);<o:p></o:p>

document.ProcessParagraphs();<o:p></o:p>

document.Save(“c:/pdftest/LargeDocument.pdf”);

The issues you have found earlier (filed as PDFNEWNET-39974) have been fixed in Aspose.Pdf for .NET 11.1.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi team,

We have tested with the new package 11.1.0 you said above, but the problem is still existing in our product, it hangs on step "document.ProcessParagraphs();". Can you please look at it again in your new build? It means a lot to us since the issue is really bad and urgent on our side.


Thanks,

Zhao

Hi Zhao,


We are sorry for the inconvenience. We have tested your above shared code with Aspose.Pdf for .NET 11.1.0 and unable to notice the issue. We will appreciate it if you please share your environment details and sample project to replicate the issue.

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

Aspose.Pdf.Page page = pdf.Pages.Add();

var builder = new StringBuilder();

builder.Append("");

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

{

builder.Append("A");

}

builder.Append("

");

var html = new HtmlFragment(builder.ToString());

page.Paragraphs.Add(html);

pdf.ProcessParagraphs();

pdf.Save(myDir + "HtmlFragmenttest.pdf");



We are sorry for the inconvenience caused.

Best Regards,

Hi Tilal,
Thanks for checking, here is what we used to reproduc the issue, can you try this? you will find it hangs at step: document.ProcessParagraphs();

I have attached the file “test.txt”, which contains lots of characters, although in reality we may not be using as many characters as in this attachment in in our product, but we will definitely use many HtmlFragment, so this issue will happen frequently, can you try with it?

try
{
Console.WriteLine(DateTime.Now.ToString());
var pdfLicense = new License();
pdfLicense.SetLicense(“Aspose.Total.lic”);
Document document = new Document { PageInfo = { Width = PageSize.A4.Width } };
var page = document.Pages.Add();
Table pageTable = new Table();
page.Paragraphs.Add(pageTable);
var row = pageTable.Rows.Add();
var cell = row.Cells.Add();
string str = File.ReadAllText(@“C:\test.txt”);
var html = new HtmlFragment(str);
cell.Paragraphs.Add(html);
document.ProcessParagraphs();
document.Save(@“C:\TestPDF.pdf”);
Console.WriteLine(DateTime.Now.ToString());
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadLine();
}
Thanks,
Zhao

Hi Zhao,

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

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNEWNET-40144) have been fixed in Aspose.Pdf for .NET 11.3.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.