I want to ask you how to render a pdf in asp.net using c#. so my web can show a pdf.
-
1Basically a duplicate of: http://stackoverflow.com/questions/5244348/generate-pdf-file-after-retrieving-the-information – PatrickSteele Mar 16 '11 at 11:45
-
4Please be more specific: do you want to be able to generate PDF's on the fly or just show pdf's in your site or just let user download PDF's from your site? It's not clear for your question. – Darius Kucinskas Mar 16 '11 at 11:47
3 Answers
You can use Aspose.PDF or iText (there is a free version).
You can read about the licensing for iText for more information on the comment provided below.

- 26,437
- 24
- 119
- 200
-
3The free version of iText uses AGPL which is a *very* restrictive license. – CodesInChaos Mar 16 '11 at 11:50
-
Good addition, I saw that but am not familiar with the actual workings of the license. I'll update the answer. – Josh M. Mar 16 '11 at 11:58
-
1As I understand it AGPL is very similar to GPL, that it affects server applications too. – CodesInChaos Mar 16 '11 at 12:01
One way is to generate latex from your application and then convert latex into pdf:
http://www.emphess.net/2010/11/09/create-high-quality-pdfs-with-razor-view-engine-and-latex
The nice thing about doing it this way is that you can write your views just like all your other views, except you use latex instead of html.

- 106,488
- 23
- 218
- 262
-
interesting line in the link "A word of warning though: RazorTex is extremely young and unstable – more sample code than anything else – so be prepared!" – V4Vendetta Mar 16 '11 at 11:51
-
Note that the blog entry is 4 months old, so I expect that it it mature a bit since then. – CodesInChaos Mar 16 '11 at 11:53
You can use the ReportViewer component (in "Local Processing Mode", so you don't need the SQL Server Reporting Services) to show a Report created in Visual Studio in a web page.
If you want the report to output directly as a PDF (instead of being shown in the ReportViewer control), you can use the technique outlined in this article to render the report on the server and then send the PDF stream to the web client:
- How to render client report definition files (.rdlc) directly to the Response stream without preview
The advantage of this solution is that you don't need to use any third-party libraries.

- 167,459
- 57
- 363
- 519