|
Rank: Member Groups: Member
Joined: 4/25/2013 Posts: 17
|
Greetings, I'm trying to make a page which will generate a PDF for a URL and prompt the user to save the file. Right now I'm just trying to do a test to render the google homepage, however, if I try to add any PostData I get a "System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt." error. Any help you could provide would be appreciated! :) Here is my code:
Code: C#
protected void Page_Load(object sender, EventArgs e)
{
//Attempt to Get Required Variables
string Name_of_Generated_PDF = string.IsNullOrEmpty(Request.Form["Name_of_Generated_PDF"]) ? "Report.pdf" : Request.Form["Name_of_Generated_PDF"];
//Set the response header
HttpResponse Response = HttpContext.Current.Response;
Response.Clear();
Response.ClearHeaders();
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", Name_of_Generated_PDF));
Response.ContentType = "application/pdf";
//NOTE: Uncommenting this line causes the Crash
//EO.Pdf.HtmlToPdf.Options.AddPostData("Export_to_PDF", "true");
//Convert to the output stream
EO.Pdf.HtmlToPdf.ConvertUrl("http://www.google.com", Response.OutputStream);
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Thanks for the testing code. We will look into it and get back to you as soon as possible.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We have posted a new build that should fix this problem. Please see your private message for the download location.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 4/17/2013 Posts: 3
|
Hello. I am having the same issue - can I get a copy of this build as well?
Thanks.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
Please see your private message for the download location.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
Is this build in the most recent version? I'm getting the same error on code that was working fine yesterday. I'm not adding any POST values to the HtmlToPDF options either.
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
NM, restarted some stuff (cleared some memory issues?) and it's working fine again...
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Thanks for the update and sorry about the issue. The original issue related to post data has been fixed. So this has to be something else. If it happens again please let us know.
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
Thanks. I'm trying to produce a small testable sample but it works every time. Must be something in my app.
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
Definitely NEVREMIND. I was trying to save to a PDF that was still open in a PDF reader!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
OK. Thank you very much for the update!
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
I should point out, however, that this error is thrown BEFORE my code, PdfDocument.Save(filePath), is reached.
So, with this:
HtmlToPdf.ConvertUrl(url, this._pdfDoc, this._options); PdfDocument.Save(filePath);
with a breakpoint on the second line, the 2nd line is not reached if the PDF in "filePath" is sitting open in another app. Weird because, moments after closing the PDF in the other app, everything works fine.
Let me know if you'd like a usable code sample and I'll whip something up.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Sure. If you have a sample that can reproduce the problem, we will be very happy to look into. We will PM you as to where to send it.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
This seems to have something to do with HighCharts and the Min- and MaxLoadWaitTime options. I have finally narrowed this bug down to the following:
When I attempt to convert a page in my app that has HighCharts on it AND I set:
Options.MinLoadWaitTime = 3000; Options.MaxLoadWaitTime = 5000;
I get the Access Violation error.
If I convert a page in my app that does not have HighCharts (or who knows what other differences) with the same Max- and MinLoadWaitTime options shown above the conversion completes without error.
If I convert a page in my app WITH HighCharts and WITH the Max- and MinLoadWaitTime options shown above the conversion completes without error.
...
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
working on a demo project now
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
all of my testing only leads to inconsistent results so I am unable so far to produce a test/demo project to send to you.
I have discovered 2 things:
1 - on my own pages that have Highcharts and Ajax-type data-grids, the error is more common than not 2 - on those same pages, if I disable my 3k millisecond MinLoadWaitTime option, the error goes away but my HighCharts and Ajax-type data grids are not rendered in time for the conversion.
This leads me to believe that EO is injecting JS to trigger the client-side convert command based on Min- and MaxLoadWaitTime options and this JS might be conflicting with something in my app's client-side framework.
Is it bad practice to use the Min- and MaxLoadWaitTime options as arbitrary wait times for client-side rendering? We have considered using the client-side, manual convert command but this seemed like it would require a lot more work for one-off PDF requests where an arbitrary, tweaked wait time would suffice.
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
I've also tested TriggerMode.Manual, triggered the conversion from the client-side using eopdf.convert() and produced the same error:
FULL EXCEPTION:
System.Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.DoEvents() at EO.Pdf.Internal.bu.a(WaitHandle A_0, Int32 A_1, h3 A_2) at EO.Pdf.Internal.dd.a(HtmlToPdfOptions A_0, String A_1, Boolean A_2) at EO.Pdf.Internal.dd.b(HtmlToPdfOptions A_0, String A_1, Boolean A_2) at EO.Pdf.Internal.dd.a(br A_0) at EO.Pdf.Internal.lu.c.a(Byte[] A_0) at EO.Pdf.Internal.a.b(BinaryReader A_0) at EO.Pdf.Internal.lu.a(a A_0) at EO.Pdf.HtmlToPdfSession.a(a A_0) at EO.Pdf.HtmlToPdfSession.a(j2 A_0, String A_1, String A_2, Int32 A_3, Int32 A_4, Boolean A_5) at EO.Pdf.HtmlToPdfSession.a(j2 A_0, String A_1, String A_2, Boolean A_3) at EO.Pdf.HtmlToPdfSession.LoadUrl(String url) at EO.Pdf.HtmlToPdf.ConvertUrl(String url, PdfDocument doc, HtmlToPdfOptions options)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Yes. The only way to avoid an arbitrary MaxLoadWaitTime value is to use the manual trigger: http://www.essentialobjects.com/doc/4/htmltopdf/eo_js.aspx#manual_triggerHowever in theory even if you trigger it early, the worst you would get is an incomplete page, not a crash. So there must be a problem somewhere. If you can PM us with the Url that you use to cause the crash, we will try it here and see if we can catch it. I understand that it is not consistent but if we can see it often, we might still be able to catch something. Thanks!
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
My app requires a session and all of this code is internal to my network. We're reviewed your JS documentation here and have a few more tests we want to run--mainly, we want to confirm that the EO browser is actually loading our page before we see this error on the server-side.
|
|
Rank: Member Groups: Member
Joined: 1/22/2014 Posts: 20
|
I finally figured out that a recent upgrade to the latest version (3.0.10) of Highcharts caused this error. Unfortunately, it seems to be a combination of Highcharts and our own application since my flat HTML file with Highcharts tests did not produce the error. Also, we had very similar errors with 2 other brands of HtmlToPdf converters. Are there any known compatibility issues with Highcharts versions higher than 3.0.2 or maybe 3.0.10 in particular?
|
|