|
Rank: Newbie Groups: Member
Joined: 6/12/2012 Posts: 2
|
Hi there
We have currently developed a web form in ASP.NET MVC, which generates a PDF of the form at the end of a wizard. During load and performance testing we are seeing a number of errors crop up out from the EO PDF generation.
Note that the PDFs being generated aren't large (at most 4 pages long) and we are using EO.Pdf.HtmlToPdf.ConvertHtml with BaseUrl set to resolve resources from physical location. I have pasted exceptions and sample code below. Any advice on how to resolve these exception would be much appreciated.
1.
EO.Pdf.Internal.ky: 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. at EO.Pdf.Internal.ll.a(a A_0) at EO.Pdf.Internal.ll.a(cp A_0) at EO.Pdf.HtmlToPdfSession.Dispose() at EO.Pdf.HtmlToPdf.ConvertHtml(String html, PdfDocument doc, HtmlToPdfOptions options) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, Stream stream, HtmlToPdfOptions options)
2.
EO.Pdf.HtmlToPdfException: Convertion failed. The operation has timed out. ---> System.Exception: The operation has timed out. at EO.Pdf.Internal.ll.a(a A_0) at EO.Pdf.HtmlToPdfSession.a(a A_0) at EO.Pdf.HtmlToPdfSession.a(jv A_0, String A_1, String A_2, Int32 A_3, Int32 A_4) at EO.Pdf.Internal.lq.a(String A_0, String A_1) at EO.Pdf.Internal.lq.a(Int32 A_0, HtmlToPdfResult A_1) at EO.Pdf.Internal.lq.d() --- End of inner exception stack trace --- at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.lq.d() at EO.Pdf.HtmlToPdfSession.RenderAsPDF(PdfDocument doc) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, PdfDocument doc, HtmlToPdfOptions options)
Implementation code:
string content = "" // <-- html here EO.Pdf.HtmlToPdf.Options.OutputArea = new RectangleF(0.4f, 0.4f, 7.8f, 10f); HtmlToPdf.Options.PreserveHighResImages = true; HtmlToPdf.Options.BaseUrl = Context.HttpContext.Server.MapPath("~/Content/"); using (MemoryStream ms = new MemoryStream()) { EO.Pdf.HtmlToPdfResult result = EO.Pdf.HtmlToPdf.ConvertHtml(content, ms); return ms.ToArray(); }
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Your code looks fine. We will try to duplicate this in our environment and keep you updated in this thread.
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
We have post a new build that should fix this problem. Please download it from our download page and let us know how it goes.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/26/2012 Posts: 3
|
Hi guys,
I have just got the latest build as we are suffering from a similar problem. The new build has not solved our problem, ours is actually live and works fine locally (have not had a chance to test multi user locally yet) however on the actual server where there are multiple people using the system it seems to time out or give a session no longer valid error more often then actually generate the pdf?
Also when it times out it just appears to be loading and never actually throws the exception so the user never knows whats happened. They just refresh the page after however long and then the page appears fine obviously no pdf actually got generated either.
I am doing further testing on this today but do you guys have any insight into a possible cause or solution to this? I hope to have more info on it in a few hours
Regards, Pete
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi Pete,
Please check your stack trace and see if it is the same as stack trace in case #1. If it is the same as that one, then almost certainly you do not have the latest build --- that one was fixed. If you have a different stack trace, please post the new stack trace and we will look further.
Case #2 can be normal under heavy load --- that can be a simple server overload. There isn't much to do for that case.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/26/2012 Posts: 3
|
Thanks for quick response
Im sorry i got case #1 this morning with the dll being updated to latest yesterday, so i dont think you are correct in saying i have the wrong build unless you are providing the wrong build in the download section of this site..? To be sure i have checked the Eo.Pdf.dll and it has its version as 4.0.18.2 is that the latest?
I believe however that i reason for getting case #1 might be valid and only get that error every now and again im more worried about case #2 since that appears more often than an actual pdf getting generated. That is i can get that error 7/10 pdf generates. You say its probably related to server load but then would i not get other server load issues like people not being able to do things on the site at all? Do you not have any suggestions for debugging or solving case #2..?
Our code is a bit more complicated that the example given in previous code but still nothing crazy technical see stack trace below as example
Exception type: HtmlToPdfException Exception message: Convertion failed. The operation has timed out. at EO.Pdf.HtmlToPdfException.b(Exception A_0) at EO.Pdf.Internal.lq.d() at EO.Pdf.HtmlToPdfSession.RenderAsPDF(PdfDocument doc) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options) at Reports_List.CreatePDFReport() at Reports_List.CreateReportLinkButton_OnClick(Object sender, EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
The operation has timed out. at EO.Pdf.Internal.ll.a(a A_0) at EO.Pdf.HtmlToPdfSession.a(a A_0) at EO.Pdf.HtmlToPdfSession.GetCurrentUrl() at EO.Pdf.Internal.lq.a(Int32 A_0, HtmlToPdfResult A_1) at EO.Pdf.Internal.lq.d()
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi, Version 4.0.18.2 is the latest build with the fix for case #1. This has been confirmed by our test and other customers who have experienced the same problem. So your problem might be a different problem related to the time out problem. As to the time out problem, try to call the same code from a SEPARATE test application first and see if you get time out. Or you can simply try to call the same Url from our sample app. If that works, then it's some kind of configuration issues on your server. This link explained a very common issue that can cause time out for you: http://www.essentialobjects.com/doc/4/web/aspxtopdf.aspx#debug
Another very common problem is if you try to duplicate session cookies, then you will run into deadlocks with ASP.NET as ASP.NET serializes requests from the same session. You can avoid that case by using our ASPXToPDF control. If none of those works for you, then we will need a test app in order to investigate further. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/26/2012 Posts: 3
|
Thanks again for the quick response. I think i should give a bit more detail of what we are doing as it might be part of the issue. Basically i am converting mutliple urls into one pdf, our report structure allows users to select parts they want or dont want included and based on that it chooses which urls to convert. On top of this 2 parts of the report are coming from external pdfs which are merged into the report. Again this all works fine locally on my machine but then im only one user. Whats interesting is that i can still make the bug happen with just including 1 part of the report thus 1 url to convert. But could it be an issue with calling multiple urls for conversion? Please see a section of the code below and NOTE the MaxLoadWaitTime and MaxConcurrentTasks values are me attempting to see if they relate to the issue (those values dont seem to help at all).
Code: C#
PdfDocument doc = new PdfDocument();
doc.Info.Title = "title";
doc.Info.Creator = "creator";
doc.Info.CreationDate = DateTime.Now;
HtmlToPdfOptions options = new HtmlToPdfOptions()
{
MinLoadWaitTime = 1000,
PageSize = PdfPageSizes.A4,
AutoFitX = HtmlToPdfAutoFitMode.None,
AutoAdjustForDPI = false,
MaxLoadWaitTime = 10000
};
options.AfterRenderPage = new PdfPageEventHandler(On_AfterRenderPage);
HtmlToPdf.MaxConcurrentTaskCount = 100;
options.OutputArea = new RectangleF(0.15f, 0.15f, 8.0f, 11.4f);
string fileName = DateTime.Now.ToString("yyyyMMdd")+"-"+UserID+"-Report"+".pdf";
string pdfFileName = Server.MapPath("~/test_html_image") + "/" + fileName;
string hostUrl = "http://" + Request.ServerVariables["HTTP_HOST"].ToString();
HtmlToPdfResult result = HtmlToPdf.ConvertUrl(hostUrl + ResolveUrl(string.Format("~/report-coverpage.aspx?id={0}&uid={1}", ProjectRevision_Id, UserID)), doc, options); //fix up the url
PdfBookmark newBookmark = new PdfBookmark("Cover page");
newBookmark.Destination = new PdfDestination(doc.Pages[result.LastPageIndex], PdfDestFitMode.EntirePage);
doc.Bookmarks.Add(newBookmark);
options.OutputArea = new RectangleF(0.15f, 1f, 8.0f, 10f);
options.FooterHtmlPosition = 11f;
int currentBookmarkPageIndex = doc.Pages.Count - 1;
if (BillOfMaterialsCheckBox.Checked)
{
result = HtmlToPdf.ConvertUrl(hostUrl + ResolveUrl(TestHtmlReportHyperLink.NavigateUrl) + "&ml=1", doc, options);
newBookmark = new PdfBookmark("materials");
newBookmark.Destination = new PdfDestination(doc.Pages[currentBookmarkPageIndex+1], PdfDestFitMode.EntirePage);
doc.Bookmarks.Add(newBookmark);
currentBookmarkPageIndex = result.LastPageIndex;
}
if (UnitBreakDownLabelCheckBox.Checked)
{
result = HtmlToPdf.ConvertUrl(hostUrl + ResolveUrl(TestHtmlReportHyperLink.NavigateUrl) + "&ud=1", doc, options);
newBookmark = new PdfBookmark("details");
newBookmark.Destination = new PdfDestination(doc.Pages[currentBookmarkPageIndex+1], PdfDestFitMode.EntirePage);
doc.Bookmarks.Add(newBookmark);
currentBookmarkPageIndex = result.LastPageIndex;
}
if (SchematicCheckBox.Checked)
{
options.AutoFitX = HtmlToPdfAutoFitMode.ScaleToFit;
options.AutoAdjustForDPI = false;
result = HtmlToPdf.ConvertUrl(hostUrl + ResolveUrl(TestHtmlReportHyperLink.NavigateUrl) + "&pd=1", doc, options);
newBookmark = new PdfBookmark("schematic(s)");
newBookmark.Destination = new PdfDestination(doc.Pages[currentBookmarkPageIndex + 1], PdfDestFitMode.EntirePage);
doc.Bookmarks.Add(newBookmark);
currentBookmarkPageIndex = result.LastPageIndex;
}
the if (...Checked) sections (3 above) continue with another 3 doing similar things, as you can see above they all call the same url with a different query stirng (that url decides what to show based on query string). You will also notice in the last one there is a change to the options to allow a better render of that part of the report. These options are returned to normal after that, you will also notice a after render event is attached which is included below for header and footer. Can you take a look at comment if anything sticks out as problematic in a server environment?
Code: C#
private void On_AfterRenderPage(object sender, PdfPageEventArgs e)
{
string HeaderHTML = GetPdfReportHeader();
string FooterHTML = GetPdfReportFooter().Replace("{{Page}}", e.Page.Index.ToString());
if (e.Page.Index > 0)
{
EO.Pdf.HtmlToPdf.Options.OutputArea = new RectangleF(0.15f, 0f, 8.0f, 1f);
EO.Pdf.HtmlToPdf.ConvertHtml(HeaderHTML, e.Page);
EO.Pdf.HtmlToPdf.Options.OutputArea = new RectangleF(0.15f, 11.1f, 8.0f, 0.9f);
EO.Pdf.HtmlToPdf.ConvertHtml(FooterHTML, e.Page);
}
else
{
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
We will need you to isolate the problem into a test app so that we will be able to run it inside our environment to duplicate the problem. We will PM you as to where to send the test application.
Thanks!
|
|