Rank: Newbie Groups: Member
Joined: 4/15/2013 Posts: 5
|
I am trying the trial version to see if I can integrate eo.pdf into a rather complex application.
I've been searching the forums and help files and trying many different things for a few days before I gave in and posted this.
The authentication method used throughout the application is based on session variables.
I'm simply trying to pass the session variables into the HtmlToPdfSession object.
Is this possible? the Session.Fill doesn't seem to add to the session.cookies
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Yes. It is possible but you have to understand how session works. Session exists on the server side, not on the client side. To your web server, the HTML to PDF converter is a client, acting very much the same way as a browser. The browser does not keep your session variables.
What the browser usually has (and keeps) is a "session id", which usually is a cookie but may not always be the case. For example, ASP.NET supports "cookieless session" that will pass the session Id in the form of query string. In all cases, if you want to request to pick up session variables on the server side, you must correctly pass the "session Id" to the server. Once the server sees a valid session Id, it uses that Id to look up all your session variables and make them ready to your page for that request. So if your session is based on cookies, then you must pass the cookies.
The HtmlToPdfSession class you see in our library is conceptually similar to your server side session but it is not the same. You can imagine this class as a "browser window". For example, you can open a browser window, log into your website with one user, log out, then log in as another user, depending on how session is configured on your server, these may result in two different server sessions. But the whole process can be done with one HtmlToPdfSession object.
Hope this helps.
Thanks!
|
Rank: Newbie Groups: Member
Joined: 4/15/2013 Posts: 5
|
Thanks for the reply. I'm not at all sure how to get the HtmlToPdfSession to use the current session variables. I tried the following where I create the HtmlToPdfSession as "SessionX", I use the applications Session as "MySession" I more or less loop through the MySession Object and then plug them into the SessionX object as cookies. Am I barking up the wrong tree?
Code: Visual Basic.NET
Dim MySession As Object = HttpContext.Current.Session
Dim I As Integer
Dim SessionCount As Integer = MySession.Contents.Count
Dim response As HttpResponse = HttpContext.Current.Response
Dim cookie As System.Net.Cookie
response.Clear()
response.ClearHeaders()
response.ContentType = "application/pdf"
Using SessionX As HtmlToPdfSession = HtmlToPdfSession.Create()
For I = 0 To SessionCount - 1
cookie = New System.Net.Cookie(MySession.Contents.Keys(I), MySession.Contents.Item(I))
EO.Pdf.HtmlToPdf.Options.Cookies.Add(cookie)
Next
EO.Pdf.HtmlToPdf.Options.PageSize = New Size(8.5F, 11.0F)
EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(0.2F, 0.2F, 7.5F, 10.5F)
EO.Pdf.HtmlToPdf.ConvertUrl(URL, response.OutputStream)
End Using
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,195
|
Hi,
Yes. Your code is completely wrong and you are clearly confused about your session variables and cookies. Cookies and session variables are often related but they are still two totally different things. So you can not just stuff your session variables into a System.Net.Cookie and hope it will work. If you want to understand these two things, you will want to read more about those. These are basic Web programming concepts so our support is not in a position to explain those to you.
Another option for you is to use ASPXToPDF control. That control automatically handles sessions for you.
Thanks!
|