Menu

EO.Pdf by Essential Objects – Extending to include ASP.net cookie authentication

Problem

EO.Pdf  has its own internal browser to generate the PDF, therefore ASP.net /MVC cookies are not shared across EO.Pdf  and ASP.net. When you ret to generate PDF using HtmlToPdf.ConvertUrl(“your url”,pdfDocument); you will probably get your unauthorised page or Login page in the PDF that is generated.

Solution

The solution is to add asp.net/mvc cookie to HtmlToPdfOptions. Wrote an extension method include the cookies, like below

in your PDF generation code you can use it like below

 

Leave a comment