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

Free Support Forum - aspose.com

Converting big HTML to PDF generate an OutOfMemoryException

Hi, I tried to convert an HTML file to a PDF by following simple code:

string inputHtml = “source.html”;
string outputPDF = “dest.pdf”;
Aspose.Pdf.HtmlLoadOptions options = new Aspose.Pdf.HtmlLoadOptions();
options.PageInfo.Margin.Left = 20;
options.PageInfo.Margin.Right = 20;
options.PageInfo.Margin.Top = 25;
options.PageInfo.Margin.Bottom = 25;
Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(inputHtml, options);
pdf.Info.Clear();
pdf.Save(outputPDF);

But this operation generates (after a long time) an OutOfMemoryException for a big html like the attached one.

Can you help us to solve the problem?source.zip (26.0 KB)

@itconsult.developer

Thank you for contacting support.

We have worked with the data shared by you but have not been able to reproduce OutOfMemoryException in our environment. The program consumes more than 3GB of memory with Aspose.PDF for .NET 19.1 and converts it to a PDF document after some minutes. However, we have logged your concerns under ticket ID PDFNET-46019 in our issue management system for further investigations. We will let you know as soon as some significant updates will be available in this regard.

dest.pdf

Hi, thank you for the support.
Today I tried it again in my development PC, just after started in morning, and it works in about 2 minutes.
But, we use this convertion in a web application and if the server has not enought resources (memory, processor?) it can fails or, anyway, it requires too much time for a responsive interface.

I’ll wait for any news about the ticked PDFNET-46019.
Thank you again.

@itconsult.developer

Thank you for the information.

We have recorded your concerns and will let you know as soon as some significant updates will be available.