Rank: Newbie Groups: Member
Joined: 1/13/2015 Posts: 1
|
We are getting a OutOfMemoryException when we try to generate a pdf from url, this pdf will have 60 pages. We are using this code:
HtmlToPdf.Options.SaveImageAsJpeg = true; HtmlToPdf.Options.NoCache = true; HtmlToPdf.Options.NoLink = false; HtmlToPdf.Options.MaxLoadWaitTime = 99999999; var doc = new PdfDocument(); var htmlToPdfResult = HtmlToPdf.ConvertUrl(url, doc);
And we get this error
Server Error in '/' Application.
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.IO.MemoryStream.ToArray() at EO.Pdf.Internal.bd.a() at EO.Pdf.Internal.de.a(b9 A_0) at EO.Pdf.Internal.lp.c.a(Byte[] A_0)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.IO.MemoryStream.ToArray() at EO.Pdf.Internal.bd.a() at EO.Pdf.Internal.de.a(b9 A_0)
This something that we have to add to fixed this error. Thanks
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Please check if you have any huge images in your HTML. 60 pages by itself is not uncommon, but if you have a lot of huge images, then you can run out of memory very quickly. In that case you can try to lower HtmlToPdf.Options.JpegQualityLevel (between 1 to 100) and see if it helps. If that still does not help, then you will want to consider splitting your HTML into multiple smaller HTML file, then convert each one of them separately, then use PdfDocument.Merge to merge them together.
Thanks!
|