Generating PDF Report from database in C#, specifically ASP
Solution 1
I've used iTextSharp with very good results. It is an open-source .NET port of a java library. It works really well for creating PDFs from scratch. Remember that editing PDFs will always be hacky with any library, because PDF is an output format, not a read-write format.
Provided your HTML is fairly clean (remove javascript postbacks, anchors, ...),the iText HtmlWorker
can convert HTML to PDF, if you prefer that route.
HTML to PDF in using iTextSharp:
Document doc = new Document(PageSize.A4);
HTMLWorker parser = new HTMLWorker(doc);
PdfWriter.GetInstance(doc, Response.OutputStream);
Also here.
Solution 2
I have used two other PDF report libraries with great success; Active Reports and Telerik Reporting. Personally I prefer the latter when it comes to programmatic control of layout and such.
Solution 3
I would suggest using .Net ReportViewer control in local mode (no report server required). It works in both webforms and winforms. You create a client-side report (.rdlc) file (which contains all the visuals as well as placement of data fields), link it up to the ReportViewer, and supply the data (DataTable or collection of objects, as long as the fields match, it doesn't matter). In client mode it supports exporting to pdf and excel (and Word too? don't remember). By default these done by a dropdown in the control itself however you can programmatically export to any of the supported formats as well. You'll end up with a byte array you can shove into a file stream.
Basically you get most of the good parts of SSRS without all of that backend complexity. There should be a ReportViewer folder in %programFiles%\Microsoft Visual Studio 10.0\ReportViewer - but versions exist for 2005 and 2008 as well. Check out http://gotreportviewer.com/
Solution 4
Use SSRS, it has a built in PDF rendering mode.
Solution 5
Take a look also at the DevExpress Reporting (non-free 3rd party tool):

Ryan Weir
I'm a full stack developer with a strong background in both the Microsoft and Java stacks, with a focus on cloud computing services (Amazon Web Services, Azure) http://ryanweir.ca
Updated on June 04, 2022Comments
-
Ryan Weir over 1 year
I need to generate a high quality report based on information in a SQL Server database, and I want very explicit control of the layout and appearance from inside C#.
I have several choices that I know of that are already being used for various other reports at our company:
1) SQL Server's built in Reporting Services
2) Adobe Forms
3) Crystal Reports
This information I need as PDF directly parallels what is already being displayed in the user's web browser as HTML, so creating a print stylesheet and converting the browser body to PDF is an option as well.
So this creates option 4:
4) JavaScript convert HTML to PDF (my preference at this time)
Does anybody have a recommendation as to which approach I should take, or even better an alternative? All the choices seem pretty horrible.
-
Tigran over 12 yearsWhat does scary you in MS Reporting Service? It,s pretty awesome. I personally would definitely prefer it to CrystalReports.
-
marc_s over 12 yearsOf those four: SQL Server Reporting Services - hands down. By far the best of those options, in my opinion.
-
jk. almost 12 yearsThere is also a tutorial out there Output SQL Server Reporting Services (SSRS) Report as PDF from URL with VB.NET or C#.NET that may help someone.
-