0

I am trying to save asp.net webpage response as pdf,but what it happens when i tried to open the generated pdf file,,it shows adobe reader could not open the file because it is either not a supported file or because the file has been damaged.

Here is the code i tried

**Response.ClearHeaders()

Response.AppendHeader("Content-disposition", String.Format("attachment;filename={0}", "Report.pdf"))

Response.ContentType = "application/pdf"**

Thanks.

1 Answers1

2

You cannot simply set the response as pdf. You can use a library like itexsharp to get a pdf version of the web page http://sourceforge.net/projects/itextsharp/

OuSs
  • 434
  • 3
  • 8
  • But actually i tried a sample web page which consists of only one label,the above code generate pdf file. i followed this link http://stackoverflow.com/questions/1072814/c-sharp-asp-net-write-file-to-clientk – Venkadesh Thirunamam Mar 11 '14 at 14:59
  • in the link that you mentionned the pdf file is already on the server and he was seeking for a way to deliver it to the client. In your case, need to parse the html generated by your asp page, convert the content to pdf and then transmit it to the client. In this case, itextsharp is the library that converts your asp page to a pdf file. – OuSs Mar 11 '14 at 15:21
  • ok thanks,I have one more doubt if i want to convert to word instead of pdf,which one prefer to use? already i researched itextsharp not supported word format. – Venkadesh Thirunamam Mar 11 '14 at 18:24