Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What options do I have to produce a PDF report from code in .NET for scientific data (winforms)

I have a "legacy" VB.NET application (winforms) written for .NET 1.1, and re-compiled under 2.0 that produces a report in HTML via a custom XmlTextWriter wrapper that is suited for HTML. The user then would print the report into pdf if they wanted to.

That was 2003, and now technology has changed a bit, especially within the C#/VB.NET world, and customers want to skip the HTML part, and go to PDF directly. What are my options for open source, or low cost PDF libraries that work well with .NET and must support tables with pictures (generated bitmaps from code) and text.

Here is screen shot of the resulting html rendering

HTML Report

Obviously this needs some cleaning up, tidying it and stuff, but I am interested on known which technology to pursue in this project.

This related question might be what I need, or it may be out of date by now. I don't have any data sources that will provide all the information I want displayed. Currently it is collected from various classes within the application in order to be displayed as html.

anybody have direct experience with iTextSharp or SharpPDF ?

Thanks for any advice.

Update 1: found possible duplicate here.

like image 722
John Alexiou Avatar asked Feb 24 '23 20:02

John Alexiou


1 Answers

I have used iTextSharp to produce PDF reports before. Although you have to get used to the library (and it is an extensive library), once you get the hang of it it isn't so bad. I found the book iText In Action to be very helpful. Even though the book is about the original Java library, not the .NET port, most of the methods and classes are named the same so it wasn't really a problem.

My #1 piece of advice when working with iTextSharp is that you'll be writing a lot of the same code, over and over again. (i.e. creating a table cell, setting the fonts, sizes, colors, and borders for that table cell, setting text...). Do yourself a favor and make your own little Utility class that will do all of your gruntwork for you -- otherwise you'll end up with 2000 lines of code that just create a few tables with some special formatting.

In addition, this site has a series of brief articles that I found useful when I was first learning iTextSharp.

Edit:

If you're interested in an XHTML-->PDF converter, I just found this blog post by Darin Dimitriov that shows how to port the open-source Java flying-saucer library to .NET. He makes it look easy!

Interestingly enough, it seems that flying-saucer uses iText under the hood to perform the conversion.

like image 82
Pandincus Avatar answered Apr 07 '23 21:04

Pandincus