Welcome Guest Search | Active Topics | Sign In | Register

ASPXToPDF & SharePoint Options
Joren
Posted: Tuesday, September 4, 2012 12:03:49 PM
Rank: Newbie
Groups: Member

Joined: 9/4/2012
Posts: 9
Hi,

I'm currently trying to generate a PDF from an aspx page hosted in SharePoint 2010. I've tried using the HtmlToPdf method but this returned a pdf of the login form.
Adding the FedAuth cookie (the application uses forms authentication) to the HtmlToPdfOptions didn't help either. But this is probably due to my conversion from a HttpCookie to a System.Net.Cookie.

I also tried the ASPXToPDF but that gives me the following error (the page url is http://servername/sites/gamma-be/_layouts/IG.PDF/Message.aspx):

Unable to automatically create file eo_web.ashx on your application root directory. The file is needed for EO.Web Controls to function. Please manually copy it from EO.Web Controls installation directory to your application's root directory.


Stack Trace:

[Exception: Unable to automatically create file eo_web.ashx on your application root directory. The file is needed for EO.Web Controls to function. Please manually copy it from EO.Web Controls installation directory to your application's root directory.]
EO.Web.Internal.fh.c() +701
EO.Web.Internal.fh.a(Boolean A_0, HttpApplication A_1) +648
EO.Web.Control..ctor(Type implType) +150
EO.Web.ASPXToPDF..ctor() +76
ASP._layouts_ig_pdf_message_aspx.__BuildControlCTRL_AspxToPdf() in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\IG.PDF\Message.aspx:44
ASP._layouts_ig_pdf_message_aspx.__BuildControlHtml1() in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\IG.PDF\Message.aspx:11
ASP._layouts_ig_pdf_message_aspx.__BuildControlTree(_layouts_ig_pdf_message_aspx __ctrl) in c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\IG.PDF\Message.aspx:1
ASP._layouts_ig_pdf_message_aspx.FrameworkInitialize() in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\a15a8c11\a1e0060b\App_Web_message.aspx.d1bf5d35.s1avgcvf.0.cs:0
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +55
System.Web.UI.Page.ProcessRequest() +91
System.Web.UI.Page.ProcessRequest(HttpContext context) +240
ASP._layouts_ig_pdf_message_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\root\a15a8c11\a1e0060b\App_Web_message.aspx.d1bf5d35.s1avgcvf.0.cs:0
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171

Any help would be much appreciated.
Regards,

Joren
eo_support
Posted: Tuesday, September 4, 2012 1:01:07 PM
Rank: Administration
Groups: Administration

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

To solve that particular problem you can just run your site locally, get the eo_web.ashx file and then copy it to your server application's root folder. That file is needed for EO.Web.dll to function. If it doesn't see that file, it will try create it ---- however that may fail if your application does not have write permission.

However I do not believe this will solve your original problem: ASPXToPDF does not duplicate FedAuth cookie either. FedAuth cookie is used by Claims Authentication and you have to have that in order to pass your server's authentication --- otherwise you will get the login screen. So ultimately you have to duplicate the cookie correctly.

Thanks!
Joren
Posted: Wednesday, September 5, 2012 1:18:16 PM
Rank: Newbie
Groups: Member

Joined: 9/4/2012
Posts: 9
Hi,

I managed to solve the cookie problem by adding it to the AdditionalHeaders property of the HtmlToPdfOptions.

options.AdditionalHeaders = new string[] { "Cookie: " + this.Page.Request.Headers["Cookie"] };

This solves the problem when a user initiates the conversion. For conversions without an HttpRequest, I had to extend the web application to a different zone (different IIS site) with windows authentication and use the options.UserName & options.Password properties.
This isn't really optimal, since I had to include credentials in the web.config. Is it possible to have the HtmlToPdf function run with the current user's credentials?

Regards,

Joren
eo_support
Posted: Wednesday, September 5, 2012 1:38:56 PM
Rank: Administration
Groups: Administration

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

The HTML to PDF converter supposes to automatically take your calling thread's user credential. Note these are two different type of authentications: When you pass user name and password, it's the "Basic Authentication", when it uses the calling thread's user token, it's "Integrated Windows Authentication". So you can try to turn that on and see if it works.

Note the calling thread's user credential may not be the same as the client user's credential. For example, it's very typical for IIS to always run under a special user "IUSER_xxxx". In that case because our converters run on your webserver, it would take the "IUSER_xxxx" user context, instead of the client user's user context.

Thanks!


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.