Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I am using iTextSharp for creating PDF for reports in ASP.Net (c#).
Pdf is created successfully & can be opened when running the Application, but when iam hosted in IIS it cannot open in PDF and gives error :

"adobe reader could not open pdf because it is either not a supported file type or because the file has been damaged "

My code like:

C#
            Document pdfDoc = new Document();
            pdfDoc.SetPageSize(PageSize.A4.Rotate());

            string filepath = "Demo" + ".pdf";

            string attachment = "attachment; filename=" + filepath;
            Response.Charset = String.Empty;
            Response.ClearContent();
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/PDF";

            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
 
            pdfDoc.Open();

            //Adding some paragraph in to the pdfdoc.            

            pdfDoc.Close();

            Response.Write(pdfDoc);
            Response.End();



Please help me!!

I am waiting for your greatfull ideas !
Posted
Comments
ZurdoDev 8-Nov-12 15:24pm    
I would make sure the path is accurate.
Adersh Ram 9-Nov-12 3:57am    
Hi Ryan,
I resolved the issue.
Problem is loading an image logo to pdf page, so i just take image from a memmory stream.

Thanks for your reply.
@CodeRelam 23-Jan-13 1:33am    
Hi, I have the same problem, how do I take a image from the memory stream

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900