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

Free Support Forum - aspose.com

HTML to PDF - Initial Slow Saving

Hi,

We are encountering an issue where the initial saving of PDF (using HTML conversion support) is taking significantly longer than subsequent saves. This performance issues appears to be process-specific. Is there a way to pre-load the library so that the initial call doesn't have to be so lengthy? Ideally, this would be a one-time call when the application starts up - any subsequent saves would be fast, and consistent, no matter if called from the same process or different processes.

Here is an example to illustrate:

DateTime start1 = DateTime.Now;
var doc = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = doc.Sections.Add();
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(section, "Hello world!!!");
text.IsHtmlTagSupported = true;
text.IsHtml5Supported = true;
section.Paragraphs.Add(text);
doc.Save("c:\\Temp\\Test.pdf");
DateTime end1 = DateTime.Now;

Console.WriteLine("First Time Seconds: " + end1.Subtract(start1).Seconds);

// First Time Seconds: 40 SECONDS

DateTime start2 = DateTime.Now;
doc = new Aspose.Pdf.Generator.Pdf();
section = doc.Sections.Add();
text = new Aspose.Pdf.Generator.Text(section, "Hello world!!!");
text.IsHtmlTagSupported = true;
text.IsHtml5Supported = true;
section.Paragraphs.Add(text);
doc.Save("c:\\Temp\\Test.pdf");
DateTime end2 = DateTime.Now;

Console.WriteLine("Second Time Seconds: " + end2.Subtract(start2).Seconds);

// Second Time Seconds: 0 SECONDS

Console.ReadLine();

Hi Maria,


<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>Thanks
for using our products.<o:p></o:p>

I have tested the scenario using Aspose.Pdf for .NET 8.0.0 and as per my observations, the first attempt took 11 seconds to generate the PDF file whereas the subsequent request was completed in 0 second. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-35378. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Is there any update on this issue. We are experiencing the same problem.

Hi Ravindra,


Thanks for your inquiry. I’m afraid the reported performance issue is still not resolved completely due to the complexity of the issues. Our development team is working hard to resolve it ASAP along with other priority tasks. However, we will update you via this forum thread as soon as we make a significant improvement towards the solution.

Thanks for your patience and cooperation.

Best Regards,

Hello,


any update about the issue?

I have the same behavior(with version 9.7.0): first save of a Pdf takes 30 seconds and subsequents are almost instant.

Thanx

Hi Ravindra,


Thanks for your inquiry. Please use new DOM approach to add HTML text in PDF document, It is more efficient and improved. Please download and try latest version of Aspose.Pdf for .NET, it will help.


DateTime start1 = DateTime.Now;<o:p></o:p>

// Instantiate Document object

Document doc33 = new Document();

// Add a page to pages collection of PDF file

Page page = doc33.Pages.Add();

// Instantiate HtmlFragment with HTML contnets

HtmlFragment titel = new HtmlFragment("Hello world!!!");

// Set bottom margin information

titel.Margin.Bottom = 10;

// Set top margin information

titel.Margin.Top = 200;

// Add HTML Fragment to paragraphs collection of page

page.Paragraphs.Add(titel);

// Save PDF file

doc33.Save(myDir+"output.pdf");

DateTime end1 = DateTime.Now;

Console.WriteLine("First Time Seconds: " + end1.Subtract(start1).Seconds);

Console.ReadKey();

Please feel free to contact us for any further assistance.


Best Regards,

Hi Laurent,


Thanks for contacting support.

Adding more to Tilal’s comments, please note that the development team has further investigated the issue reported earlier and we have made some improvements regarding HTML to PDF conversion in recent release of Aspose.Pdf for .NET 9.7.0. However, please note that it is a known problem and has been extensively discussed in .NET forums. You may consider searching for solution over the internet i.e. Google something like “first call is long in C#” and it can be resolved by configuring IIS or by introducing some changes/configurations on your application side. I am afraid It does not seem to be an issue with our API.

Thanks for your comprehension.

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


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