0

I have a Web application which implemented in MVC (Razor) environment. Inside this application, there is a page that shows data from SQL Server(using Entity Framework) with WebGrid.

I want to know that how can I embed a button to download this WebGrid data as a PDF file?

Thanks in advance.

Michael Petrotta
  • 59,888
  • 27
  • 145
  • 179
Raha
  • 163
  • 1
  • 2
  • 12

1 Answers1

1

You will need a third party component to generate the PDF since .NET doesn't natively include anything that does that. I recommend iTextSharp. Then you just obtain the data from the database and construct a PdfPTable object which you include in a Pdf document.

I have written an article that includes complete code here: http://www.mikesdotnetting.com/Article/205/Exporting-The-Razor-WebGrid-To-PDF-Using-iTextSharp

Mike Brind
  • 28,238
  • 6
  • 56
  • 88