The performance for HtmlFragment

Hi

Our code uses a lot of HtmlFragment objects in pdf file. We found that the export PDF for a long time.My test code is as follows:
var html = new HtmlFragment("
aaa
");
for (int i = 0; i < 100; i++)
{
page.Paragraphs.Add(html);
}

PDF generation time is 40 seconds,We can improve the efficiency of here?Expect your reply.

Hi Zhao,


Thanks for your inquiry. I have tested your shared sample code on Win7 64 bit, 8GB ram and Aspose.Pdf for .NET 11.0.0, it took almost 13 seconds at my side.

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

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

var html = new HtmlFragment("

aaa
");

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

{

page.Paragraphs.Add(html);

}

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


Furthermore, please note Aspose.Pdf processes in memory instead disk so performance depends upon the file size/contents and system resources.

Please feel free to contact us for any further assistance.

Best Regards,

Hi Tilal Ahmad,
Thanks for your reply.I think I probably know the reason.In my real machine test and 13 seconds.But the same code to test in the virtual machine is 40 seconds.
My virtual machine memory is 16G.So I think it has nothing to do with memory size.I guess our efficiency and memory on the actual performance?
Because of the virtual machine memory and the actual machine after all not the same.Because customers can install our products in their virtual machine.
So I think the problem still need to improve the best.Can be in your virtual machine test this problem.Look forward to your reply.Attachment is my virtual machine configuration information.

Hi Zhao,


Thanks for your feedback. Sure we will test the scenario in VM as well and update you our findings.

Best Regards,

Hi Zaho,


Thanks for your patience. I have tested the scenario over Windows server 2012 R2 VM and noticed it is taking almost 15 seconds. We will appreciate it if you please test the scenario at some other machine at your end and share the results, as it seems its machine specific issue.

Stopwatch sw = new Stopwatch();<o:p></o:p>

sw.Start();

Document pdf = new Document();

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

var html = new HtmlFragment("

aaa
");

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

{

page.Paragraphs.Add(html);

}

pdf.Save("C:/temp/HtmlFragmenttest.pdf");

sw.Stop();

Console.WriteLine(sw.Elapsed.TotalSeconds);

Console.ReadLine();


We are sorry for the inconvenience caused.


Best Regards,

Hi Tilal,

what we need to use in our software is more than 100 HtmlFragment, there could be thousands of HtmlFragment, can you please improve your performance more? or can you let me know whether you have new build which already enchanced this? please advise.

Thanks,
Zhao

Hi Zhao,


Thanks for your feedback. We had made lot of improvements in our API, I will appreciate it if you please test the latest release of Aspose.Pdf for .NET and share the results. I tested the scenario with 100 HtmlFragment as per your code snippet, however I will test the scenario again with more number of HtmlFragments and share the results.

We are sorry for the inconvenience caused.

Best Regards,

Hi Zhao,


In reference to HtmlFragment performance, as requested did you get change to test the scenario with latest release?

However, I have created a PDF document with 1000 HtmlFragments and noticed that it is taking almost 100 seconds, so I have logged an enhancement ticket PDFNEWNET-40200 in our issue tracking for further investigation and resolution. We will keep you updated about the issue resolution progress.

We are sorry for the inconvenience caused.

Best Regards,

The issues you have found earlier (filed as PDFNET-40200) have been fixed in Aspose.PDF for .NET 18.5. This message was posted using BugNotificationTool by asad.ali

We also have this issue.
Using the latest Aspose,PDF for .net 18.5, it takes about 180 seconds for 1000 htmlfragments. This is the code I am using. Is there something I am doing wrong? Is this issue resolved?

This is the code I am using:

        Stopwatch sw = new Stopwatch();
        Aspose.Pdf.License license = new Aspose.Pdf.License()
        {
            Embedded = true
        };
        license.SetLicense("Aspose.Pdf.lic");
        sw.Start();
        Document pdf = new Document();
        Page page = pdf.Pages.Add();
        for (int i = 0; i < 1000; i++)
        {
            page.Paragraphs.Add(new HtmlFragment("aaa"));
        }
        pdf.Save("C:/temp/HtmlFragmenttest1.pdf");
        sw.Stop();
        Console.WriteLine(sw.Elapsed.TotalSeconds);
        Console.ReadLine();

Machine is a i5-5300U with 12GB of RAM

@DenisW

Thanks for contacting support.

We managed to observe the delay in PDF Generation while using HtmlFragment and logged a performance issue as PDFNET-44828 in our issue tracking system. We will further investigate the reasons behind this behavior of the API and keep you informed with the status of ticket resolution. Please be patient and spare us little time.

We are sorry for the inconvenience.