Welcome Guest Search | Active Topics | Sign In | Register

EO.PDF - Session is no longer valid error Options
Daniel Harmon
Posted: Friday, June 19, 2015 10:44:02 AM
Rank: Newbie
Groups: Member

Joined: 6/19/2015
Posts: 2
Hello,
I am trying to run batches of html to pdf conversions locally and it makes it through about 15 and then crashes with this error. The files that aren't produced aren't incredibly big, about 300kb and looking at my memory usage, it is pretty stable. I have 10GB of free memory at all times. The html that is passed in isn't anything special (no images, no javascript), just a lot of text. However, when I remove the css (which has minimal background images for gradients and other things), it works fine. File size is about 100kb. Any ideas? I would really hate to not be able to use the stylesheet with these.

[aok: This session is no longer valid. If you wish to reuse the session later, please consider calling GetCookies to retain the session cookies, then reuse these cookies through HtmlToPdfOptions.Cookies with another session. (6)]
EO.Pdf.Internal.md.h() +183
EO.Pdf.Internal.md.a(apz A_0) +1058
EO.Pdf.HtmlToPdfSession.a(apz A_0) +144
EO.Pdf.Internal.y7.a(String A_0, Single& A_1) +465
EO.Pdf.Internal.y7.d() +302

[HtmlToPdfException: Conversion failed. This session is no longer valid. If you wish to reuse the session later, please consider calling GetCookies to retain the session cookies, then reuse these cookies through HtmlToPdfOptions.Cookies with another session. (6)]
EO.Pdf.HtmlToPdfException.b(Exception A_0) +128
EO.Pdf.Internal.y7.d() +2138
EO.Pdf.HtmlToPdfSession.RenderAsPDF(PdfDocument doc) +126
EO.Pdf.HtmlToPdf.ConvertHtml(String html, PdfDocument doc, HtmlToPdfOptions options) +161
EO.Pdf.HtmlToPdf.ConvertHtml(String html, String pdfFileName, HtmlToPdfOptions options) +111
Illinois.Common.PDF.PdfUtils.ConvertHtmlStringToFile(String html, String stylesheetUrl, String saveLocation, PdfUtilOptions pdfUtilOptions) in C:\Users\daharmon\Documents\Visual Studio 2013\Projects\Illinois.Common\Illinois.Common\Pdf\PdfUtils.vb:57


Here is my code

Public Sub ConvertHtmlStringToMemoryStream(html As String, stylesheetUrl As String, saveLocation As String, pdfUtilOptions As PdfUtilOptions)
html = "<html><head><link href='" & stylesheetUrl & "' rel='stylesheet' type='text/css' media='screen' /><style>body {padding:20px;} </style></head><body>" & html & "<p>&nbsp;</p></body></html>"

If pdfUtilOptions Is Nothing Then
pdfUtilOptions = New PdfUtilOptions
End If

Dim options As New EO.Pdf.HtmlToPdfOptions
options.PageSize = pdfUtilOptions.PageSize
options.ZoomLevel = pdfUtilOptions.ZoomLevel
options.AutoFitX = pdfUtilOptions.AutoScaleX

EO.Pdf.HtmlToPdf.ConvertHtml(html, saveLocation, options)

End Sub
eo_support
Posted: Friday, June 19, 2015 4:02:52 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

This could be an out of memory crash inside the browser engine. The gradient background would force the whole page to be rendered as a bitmap, which can significantly strain the browser engine (normally it renders everything as vector format and it's uses both very little memory and offers high quality output). The native browser engine runs inside a separate process in 32 bit mode, so it can't utilize your 10GB free memory (the .NET side code does take full advantage of 64 bit mode and extra memory).

What you can do is to use a loop to retry when you see such exception. Most of the time when you hit this error, a retry would go through because the error itself has crashed the browser engine process and a new one will be created upon the next conversion. Another method you can try is to use a separate AppDomain to run the conversions and when you run into an exception, restart the AppDomain and continue. This also has the effects of cleaning up all the memory fragmentations that might have occurred and acculmuated due to previous conversions.

Thanks!
Daniel Harmon
Posted: Friday, June 19, 2015 4:50:19 PM
Rank: Newbie
Groups: Member

Joined: 6/19/2015
Posts: 2
That seems odd that it would be a memory issue. Looking at my resource monitor, the resources do not consume more than 200MB the entire time. I have tried the "retry" method you mentioned but it doesn't seem to solve the problem. I can look into the app domain restart but I'm not sure how well this will fit in with our current architecture.
eo_support
Posted: Friday, June 19, 2015 4:59:01 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Hi,

In that case please try to isolate the problem into a test project and send the test project to us. See here for more details:

http://www.essentialobjects.com/forum/test_project.aspx

Once we have that we will be able to investigate further.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.