Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET PDF itextsharp
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:
 
            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 5-Nov-12 22:23pm
Comments
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 273
1 Maciej Los 255
2 Aajmot Sk 234
3 Richard MacCutchan 200
4 Marcin Kozub 195
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,127
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 6 Nov 2012
Copyright © CodeProject, 1999-2014
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