|
Rank: Newbie Groups: Member
Joined: 10/11/2011 Posts: 1
|
I am using you sample code similiar to below. protected void ASPXToPDF1_AfterRender(object sender, System.ComponentModel.CancelEventArgs e) { .... ... }
Question is: How to fire the event, how to get get the code in it to run?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
AfterRender is an event on the ASPXToPDF control. You handle it the same way as you handle any other control's event.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/26/2012 Posts: 3
|
Hello EO
We would like to buy your product but we can't test it works.
After all documentation, sample codes, demos, forums we can't do the below: ASP.NET, C# In Report.aspx.cs:
protected void ASPXToPDF1_AfterRender(object sender, EventArgs e) { HtmlToPdfResult result = (HtmlToPdfResult)ASPXToPDF1.Result; PdfDocument doc = result.PdfDocument; doc.Security.UserPassword = "1234"; doc.Security.OwnerPassword = "5678";);
HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ClearHeaders(); response.ContentType = "application/pdf";
doc.Save(response.OutputStream);
response.End(); }
protected void ASPxButton1_Click(object sender, EventArgs e) { ASPXToPDF1.RenderAsPDF("Report.pdf"); }
In Report.aspx: <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %> <eo:ASPXToPDF runat="server" ID="ASPXToPDF1"></eo:ASPXToPDF>
|
|
Rank: Newbie Groups: Member
Joined: 8/26/2012 Posts: 3
|
<eo:ASPXToPDF AfterRender="ASPXToPDF1_AfterRender" ..... /> doesn't works because it has no that property
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Your code looks fine except that you need to call RenderAsPDF(false). Note the argument "false" here is needed to prevent the ASPXToPDF control to send the document to the client. By default ASPXToPDF will do basically the same thing you do in your AfterRender handler. Since you are sending the files, you must pass false to RenderAsPDF so that ASPXToPDF doesn't do it again.
AfterRender is an event. It's not a property. You hook it up with OnAfterRender="....", not AfterRender="....".
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 8/26/2012 Posts: 3
|
Thanks for the quick answer. It works below for example: ASP.NET, C# In Report.aspx.cs:
protected void ASPXToPDF1_AfterRender(object sender, EventArgs e) { HtmlToPdfResult result = (HtmlToPdfResult)ASPXToPDF1.Result; PdfDocument doc = result.PdfDocument; doc.Save("Report.pdf"); }
protected void ASPxButton1_Click(object sender, EventArgs e) { ASPXToPDF1.RenderAsPDF(false); }
In Report.aspx: <%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %> <eo:ASPXToPDF OnAfterRender="ASPXToPDF1_AfterRender" runat="server" ID="ASPXToPDF1"></eo:ASPXToPDF>
but the result different like
protected void ASPxButton1_Click(object sender, EventArgs e) { ASPXToPDF1.RenderAsPDF("Report.pdf"); }
There are no pictures, colors, only text and boxes.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
There should be no difference between RenderAsPDF("Report.pdf") and RenderAsPDF(false) when it comes to the result file. The only difference between these two is RenderAsPDF("Report.pdf") will send the result to the client, while RenderAsPDF(false) will not.
If you still have problem, please try to create a test project that can demonstrate the problem and send the test project to us. Please reply again once you have the test project so that we can tell you where to send it.
Thanks!
|
|