Tuesday, 20 March 2012

ITextSharp Showing Image in the PDF using Http.Context.Current.Server.Mapath showing Error.

You will find that the application in which you had used ITextSharp is working fine in local machine,  but when you put it into the production Environment it might be showing that the Image path cannot be found or unable to access the Image path in the current context. This is due to the restriction by your Server, So in order to make it work properly just do it as given below: 


 string imagePath = HttpContext.Current.Server.MapPath("~/Styles/Images/etv-logo.png");
        iTextSharp.text.Image headerImage =
            iTextSharp.text.Image.GetInstance(new FileStream(imagePath, FileMode.OpenOrCreate));
 
Hopes it will help you, Enjoy.... 

No comments:

Post a Comment