Welcome Guest Search | Active Topics | Sign In | Register

EO.PDF ASPXToPDF or HtmlToPdf capture a different page? Options
Gabe
Posted: Wednesday, May 4, 2016 2:39:05 PM
Rank: Member
Groups: Member

Joined: 5/4/2016
Posts: 19
In an ASP.NET webforms project, we would like to have a button on a webform page that would generate a PDF from the content of another webform page (from the code behind). The ASPXToPDF control does this well for the current page. Is there a way to call and capture another webform page from code behind? I know I can use EO.Pdf.HtmlToPdf.ConvertUrl, but unlike the ASPXToPDF, it does not run in the context of the current authenticated user and does not (yet) work with our custom authentication. I'm assuming there is a way to do this, but wasn't able to find it in the documentation or forum. Thanks for any help you can provide.

Basically...
Click button on page1.aspx
Click event calls code to "render" page2.aspx (as the authenticated user) and convert it to PDF.
This resulting PDF can be read as stream for DB storage or be sent to output stream.
The user never sees Page2.aspx.
eo_support
Posted: Wednesday, May 4, 2016 3:32:30 PM
Rank: Administration
Groups: Administration

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

You can do a redirect from Page1.aspx to Page2.aspx and then call RenderAsPDF in Page2.aspx's Page_Load event. This way the user will never see Page2.aspx because Page2 is directly rendered as PDF.

Thanks!
Gabe
Posted: Wednesday, May 4, 2016 4:55:20 PM
Rank: Member
Groups: Member

Joined: 5/4/2016
Posts: 19
Thanks for the fast response! Sounds like a good solution for a direct download. What if I want to capture the PDF file stream/bytes so I can upload in to a database instead of downloading to the client? I think I can do that in the PageLoad of Page2.aspx by overwriting one of the ASPXToPDF events but how to I stop the "redirect" to nothing?
Gabe
Posted: Thursday, May 5, 2016 12:44:25 PM
Rank: Member
Groups: Member

Joined: 5/4/2016
Posts: 19
Just in case others are reading this thread, it looks like one can use Server.Execute() to execute another page in the ASP.NET application from the code-behind of a different page (without a web request). I should be able to use this to cause the PDF generation to happen on another page and use the AfterRender event of the ASPXToPDF control to capture the document and store.
eo_support
Posted: Thursday, May 5, 2016 12:53:15 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,229
Yes. That sounds like a great idea!


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.