Click here to Skip to main content
16,012,611 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
i have a view that brings the data from the database and show it in html format ,i want a button so that if u press on that it will convert to pdf ..what is the code for converting to pdf in asp.net mvc rozer file
Posted
Comments
F-ES Sitecore 22-Jun-15 9:29am    
This question is asked numerous times each day. Please do basic research such as using google before asking a question.
Member 11755579 22-Jun-15 9:35am    
but i dont find a proper answer for that one
Sergey Alexandrovich Kryukov 22-Jun-15 9:52am    
Why PDF? What's wrong with HTML? At least HTML is a part of W3 standards.
—SA

It's amazing what a little Googling will come up with.

http://www.c-sharpcorner.com/Blogs/9666/convert-html-to-pdf-in-Asp-Net-mvc-razor.aspx[^]
 
Share this answer
 
Please see my comment to the question; why PDF?

First of all, you cannot just "convert" one to another. HTML and PDF concepts are totally different, so there is no any one-to-one correspondence and cannot be. HTML is content is fluid, its rendering depends on the size of the page, and PDF presents totally fixed layout, much like a paper printout. You can only create some particular mapping onto PDF based on some particular requirement. PDF will fix only one particular rendering with one particular paper size.

To work with PDF, you can use iText, or its .NET port, iTextSharp:
http://en.wikipedia.org/wiki/IText[^],
http://itextpdf.com/[^],
http://sourceforge.net/projects/itextsharp/[^].

In included the reference to Java iText site as well, because most documentation is there. If you understand C#, it would not be difficult to understand Java-bases API documentation.

Just in case: PDF is not a part of W3 standards and may or may not be supported on client's browser. Such support is based on some plug-in implementation which may or may not be available. Moreover, you should not make an assumption that a local system has any PDF support at all. This is not a problem, because the browser can always fall back to saving a file in a local file system.

—SA
 
Share this answer
 
v4

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