|
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???
|
|
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!
|
|
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.
|
|
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!
|
|
Rank: Newbie Groups: Member
Joined: 9/22/2011 Posts: 3
|
Perfect. Works as expected. Thanks
|
|
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
|
|
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.aspxThanks!
|
|
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.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
OK. Let us know if there is anything else.
|
|