|
Rank: Newbie Groups: Member
Joined: 6/27/2010 Posts: 6
|
Hi,
I am trying to use the EO.Pdf.HtmlToPdf funtion on a forms auth web site. I have logged in and in the code behind the page I am on, I have the code below. It prints the doc Ok but always prints the logon page. Am I missing something? Thanks for your help
EO.Pdf.PdfDocument doc = new EO.Pdf.PdfDocument(); EO.Pdf.HtmlToPdf.Options.MinLoadWaitTime = 2000; EO.Pdf.HtmlToPdf.ConvertUrl("http://localhost:53978/TEST/GridControls/ReportAssessmentsByUserView.aspx", doc);
HttpResponse response = HttpContext.Current.Response; response.Clear(); response.ClearHeaders(); response.ContentType = "application/pdf";
doc.Save(response.OutputStream);
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, That's normal. Our converter does not depend on your browser so it does not share session data with your browser. This is similar to after you login with IE you will still need to login if you open a new FireFox window. The easiest solution for this is to use our ASPXToPDF control. That control is specifically designed for this situation. See here for more details: http://doc.essentialobjects.com/library/4/web/aspxtopdf.aspxThis post also gives you some background information about this scenario: http://www.essentialobjects.com/forum/postst5528_How-to-convert-a-Web-page-that-requires-login-to-PDF.aspxASPXToPDF was only added recently, so if you do not see that in your DLL (it's in EO.Web.dll, not EO.Pdf.dll), please download and install the latest EO.Web. The control is covered by EO.Pdf license, not EO.Web license. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/27/2010 Posts: 6
|
Thanks,
I tried that one too but it has the same issue - my code below:
EO.Pdf.HtmlToPdf.Options.PageSize = EO.Pdf.PdfPageSizes.A4; EO.Pdf.HtmlToPdf.Options.OutputArea = new System.Drawing.RectangleF(0.5f, 0.5f, 7.5f, 10f); EO.Pdf.HtmlToPdf.Options.MinLoadWaitTime = 2000;
//Render the result as PDF ASPXToPDF1.RenderAsPDF();
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That should not happen. Usually your login page is displayed when you try to access a protected Url. That's why when you call ConvertUrl it will hit the log in page. RenderAsPDF does not use a Url. So it should not hit your login page.
If the problem continues, please try to isolate the problem into a test project and send that to us. We should be able to tell you what's wrong right away as soon as we have that.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 6/27/2010 Posts: 6
|
It works fine with most pages. But I am using JQGrid ona number of pages - it is a jquery control which using Async postbakcs to populate the data. I put the MinLoadWaitTime on just in case the jquery hadn't run but no luck. Is there any reason you can see why this wouldn't work?
Thanks,
Stewart
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
That makes sense. As soon as you pull Url inside the converter, you will hit the login page because the converter does not have your login session, which only existed inside your browser, not inside the converter (Your browser runs on your client computer and the converter runs on your server). The converter will execute your JQuery code fine, but when JQuery makes the Async postbacks, it pulls a Url and your server will respond with the login page.
In order to work around the problem, you have to change your code to:
1. Make sure the page where you calls RenderAsPDF is the final output. No more request to the server from that point on;
-- or --
2. Make sure additional request after RenderAsPDF is handled correctly by your server. This usually means you have to add additional data in your request so that you can re-establish your identify when the request hit your server. The original post posted above that discussed this problem explained how to use query string to pass additional information. In your case, you can also use form data instead of query string since you are doing a post back (for example, rendering an additional hidden field in your page that contains an encrypted "user id"). On the server side, you can either make the page accessible to everyone, but check users identify in your page (for example, inside Page_Load), or keep the page protected and then reestablish user identity in your Application's AuthenticateRequest event handler. In any case, the idea is to make sure your server knows the request is already associated to a specific user so it no longer needs to login;
Hope this helps. Please feel free to let us know if you have any more question.
Thanks
|
|