Reputation: 173
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.
Upvotes: 0
Views: 472
Reputation: 30065
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
Upvotes: 1