Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
2.33/5 (2 votes)
I need to generate a PDF report which contains some images, costume text info and a table for my ASP.Net MVC4 application. please give me any ideas on the best way to implement this?
Posted
Updated 7-Jan-14 19:47pm
v7
Comments
Volynsky Alex 15-May-13 6:06am    
What do you say about it:
http://www.codeproject.com/Articles/260470/PDF-reporting-using-ASP-NET-MVC3
manoj.jsm 15-May-13 7:29am    
hi Volynsky Alex,
It is a nice method. now i am trying this with JQgrid and if you wish take a look at this link:
http://www.trirand.net/aspnetmvc/grid/exportpdf
what was the problem with above method is that i unable to find how to add logo and title in the header of pdf

hearty thanks my friend,
jsm
Volynsky Alex 15-May-13 8:24am    
Thank you, jsm!
Regards,
Alex.
Volynsky Alex 15-May-13 10:44am    
Well I will send, if I can find interesting information for you
Regards,
Alex
manoj.jsm 16-May-13 3:20am    
hi Alex,
that grate.

Thanks and Regards,
jsm

Follow these steps to generate an actual report from your web application:

* Create a controller that derives from PdfViewController.
* Create a view that generates the HTML which should be translated to a PDF report.
* Create an action on a controller which calls the ViewPDF method on the PdfViewController.
* Create a link to trigger the action on the controller.
* Below, these steps are described in more detail.

Create a view that should be translated to a report. This could be an existing view or a new view specially for reporting. I usually create a new view as it lets me control the HTML markup for the report. As stated earlier, the report generator does not support all the HTML markup. In the demo project, this is the PrintDemo view.

Below, the PrintDemo view from the demo project is shown. As can be seen, this is just a simple ASP.NET Razor view with a table and some rows. It uses a strongly typed model but that is not necessary. A tip when trying to design your report is to add borders to your table or div. Using these borders, when looking at the generated PDF, you can clearly see the start and end of the areas of your report

For more information,you can read the following post:
http://mvc-tutorials.com/how-to-create-pdf-report-in-asp-net-mvc3[^]
 
Share this answer
 
Comments
manoj.jsm 15-May-13 7:23am    
hi Volynsky Alex,
nice description and explanation. i had to thank u for this and previous answers.

Thanks,
jsm
Volynsky Alex 15-May-13 8:15am    
You're welcome manoj.jsm.
Regards,
Alex.
ibrahim fakeh 3-May-17 5:06am    
the link is not working
You will need to generate you report on server side and send it as content to the client. Start here: PDF reporting using ASP.NET MVC3[^].
 
Share this answer
 
Comments
manoj.jsm 8-May-13 7:09am    
hi Zoltán Zörgő,

i feel thankful for your reply.
iText appears to now have a strong copyleft license (AGPL). This means that i cannot use it as part of my commercial product. so plz tell me some other way to implement it
Zoltán Zörgő 8-May-13 7:42am    
As I know, AGLP allows you to link to the library in commercial product, but not in a closed source one. If you make a closed source commercial product, you can buy commercial license from them. There are several open source PDF libraries out there:
http://csharp-source.net/open-source/pdf-libraries
http://www.codeproject.com/Articles/10157/Gios-PDF-NET-library
http://www.pdfsharp.net/(X(1)S(j3iwpdp5f41vcxxbfoeughut))/default.aspx?AspxAutoDetectCookieSupport=1
http://www.dotnetobject.com/Thread-Html-to-Pdf-conversion-in-asp-net-c
But you will need to check every license agreement one by one if you want to earn money from the work of others.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900