Click here to Skip to main content
11,805,604 members (54,046 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET PDF itextsharp

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:

            Document pdfDoc = new Document();
            string filepath = "Demo" + ".pdf";
            string attachment = "attachment; filename=" + filepath;
            Response.Charset = String.Empty;
            Response.AddHeader("content-disposition", attachment);
            Response.ContentType = "application/PDF";
            PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
            //Adding some paragraph in to the pdfdoc.            


Please help me!!

I am waiting for your greatfull ideas !
Posted 5-Nov-12 21:23pm
ryanb31 at 8-Nov-12 15:24pm
I would make sure the path is accurate.
Adersh Ram at 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.
Julius Depulla at 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)

  Print Answers RSS
0 OriginalGriff 310
1 Richard Deeming 225
2 Sergey Alexandrovich Kryukov 170
3 Abhinav S 128
4 ppolymorphe 125
0 OriginalGriff 3,300
1 Maciej Los 1,990
2 KrunalRohit 1,907
3 CPallini 1,855
4 Richard MacCutchan 1,227

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100