Welcome Guest Search | Active Topics | Sign In | Register

ASPXTOPDF-Cancel Not working Options
ITPro
Posted: Thursday, September 22, 2011 5:35:07 PM
Rank: Newbie
Groups: Member

Joined: 9/22/2011
Posts: 3
I am using ASPXTOPDF to convert my page to PDF. Right now we are using the DEMO version to make sure everything works fine before purchasing the licensed version.
The problem we are facing is by default the page is displayed in the client side asking for open/save/cancel. We tried for afterrender event with e.cancel=true. Still its not working in the demo version. I downloaded it only yesterday. Any suggestions???
eo_support
Posted: Thursday, September 22, 2011 6:10:47 PM
Rank: Administration
Groups: Administration

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

Please check the version of both EO.Pdf.dll and EO.Web.dll. If you have just downloaded EO.Pdf yesterday, you may have an older EO.Web.dll. The canelation logic is implemented in EO.Web.dll and it does not work correctly in older versions.

EO.Pdf.dll should be 3.0.68.2 ---- if your version is older than this, download EO.Pdf
EO.Web.dll should be 9.0.25.2 --- if your version is older than this, download EO.Web

Thanks!
ITPro
Posted: Thursday, September 22, 2011 10:02:20 PM
Rank: Newbie
Groups: Member

Joined: 9/22/2011
Posts: 3
Awesome. I downloaded the new version and e.cancel works. Can you let me know how to show the pdf now.
My requirement is to automatically open the pdf on the client side without prompting for open/save/cancel.
eo_support
Posted: Thursday, September 22, 2011 10:28:15 PM
Rank: Administration
Groups: Administration

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

You will need to do something like this in your AfterRender event handler:

Code: C#
protected void ASPXToPDF1_AfterRender(
    object sender, System.ComponentModel.CancelEventArgs e)
{
    //Cancel the default behavior
    e.Cancel = true;

    //Save the PDF to the output stream directly
    Response.Clear();
    Response.ClearHeaders();
    Response.ContentType = "application/pdf";
    EO.Pdf.HtmlToPdfResult result = 
        (EO.Pdf.HtmlToPdfResult)ASPXToPDF1.Result;
    EO.Pdf.PdfDocument doc = result.PdfDocument;
    doc.Save(Response.OutputStream);
    Response.End();
}


The idea is to first get the result PdfDocument object. Once you have PdfDocument object, you can save it to anywhere.

Hope this helps.

Thanks!
ITPro
Posted: Monday, September 26, 2011 2:31:10 PM
Rank: Newbie
Groups: Member

Joined: 9/22/2011
Posts: 3
Perfect. Works as expected. Thanks
Roberto Carrera
Posted: Wednesday, May 2, 2012 12:27:56 PM
Rank: Newbie
Groups: Member

Joined: 8/15/2011
Posts: 7
Hi, i'm tring to make a clear to the Response object on AfterRender of ASPXToPDF control, but the Response object throws an HttpException with message "Response is not available in this context".

I'm using Eo.Web.dll version 9.0.37.2, and the AfterRender method is distinct because it receives a EventArgs as an argument and the method you are exposing in this thread receives a System.ComponentModel.CancelEventArgs, and if i change that argument type my application does not work.

Can you tell me where could be another place to work with the Response object after render Pdf please?

Thanks
eo_support
Posted: Wednesday, May 2, 2012 1:43:23 PM
Rank: Administration
Groups: Administration

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

The original reply to this question was for older builds and is outdated. With the newest build you do not need to clear the Response object. You would call RenderAsPDF(false) to prevent the result PDF file from being sent to the client. See here for more details:

http://www.essentialobjects.com/doc/4/web/aspxtopdf.aspx

Thanks!
Roberto Carrera
Posted: Wednesday, May 2, 2012 1:47:00 PM
Rank: Newbie
Groups: Member

Joined: 8/15/2011
Posts: 7
OK Thanks, it was intended to show pdf directly but solved it using HttpContext.Current.Response.

But thank you so much any way.
eo_support
Posted: Wednesday, May 2, 2012 2:11:50 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,195
OK. Let us know if there is anything else.


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.