Monday, March 28, 2011

Export Gridview to PDF

we have seen how to export the data from gridview to Excel file, today this post will helps you to export the gridview data to PDF, if you want protect you data being edit/ cut/ delete then Export to PDF will be a better option for you.there is a open source project for iTextShart. you can download the dll from them and you can use it.

only you need to add this content on your page

Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment; filename= SampleExport.pdf");
Response.End();


Even you can format the text also,if you want to set the page with A4 or any other even you can also do the same.you can also specify the font size, style color all the basic things you can do with it.

you can download the code from the below link. you can try that it will helps you.

download Source

5 comments:

  1. Thank you. It saved me a lot of headache and hours.

    ReplyDelete
  2. Thank you. Excelent!!!

    ReplyDelete
  3. hi you can even use entire grid-view into the pdf with password protected. you can use itextpdf which is very simple to use and just need to integrate the response on the object.

    on my comming post i will implement the same

    ReplyDelete