I typically cringe when online reporting is included in a web application’s feature list. It may just be me, but I’ve always found building professional, print-friendly reports to be very difficult, very time consuming and error prone. Notwithstanding, I have produced my fair share of dynamic PDF reports over the years and with very few exceptions has the reporting solution simply worked without sacrificing a technical requirement or implementing a clever workaround. There are a ton of .NET components available to help with report generation. For example, I have recently had some success with ActivePDF, but it has it’s short-comings so I dedicated some of last week to researching alternative solutions.
SELECTION CRITERIA
1. The component must generate/manage reports in memory rather than requiring a physical file be created. There’s no need for physical file creation and it’s best to avoid it if necessary. Simply, it eliminates the need for additional folder permissions and file cleanup.
2. The component must intelligently and inherently handle page breaks. In other words, tables, images and text positioning will be based on available page space. If appropriate, content will wrap or flow from page to page. Additionally, the ability to repeat table headers would be a plus.
3. The component must work for both web and winforms development.
4. The component must produced reports of various page size and orientation. All I need here is the ability to print in portrait or landscape.
5. The component must be inexpensive — if not free — with unlimited developer seats and unlimited number of distributions. This is because I am a cheapskate.
6. The component must have ample examples/templates must be easily available. Documentation is a nice-to-have.
7. It would be nice if the component were production-ready with a proven track record.
8. It would be nice if the component included a designer since a design view can really speed up, umm, design time.
CANDIDATES
Due to my cost requirement (read limitation), I spent most of my time evaluating open source solutions including iTextSharp, SharpPDF, Report.NET and NFop. ![]()
iTextSharp is a port to C# of the Java iText library for generating PDF files. Of all the open source options, I was most impressed with iTextSharp. It is stable and actively being developed (version 3.1.7 was released on 11/25) and it comes along with tons of documentation/samples.
Unfortunately, as best as I can tell, iTextSharp requires a physical file be generated. Essentially, a Document object is created and then the iTextSharp PdfWriter listens to the document and directs a PDF-stream to a physical file. The PdfWriter will GetInstance() of a in-memory filestream without throwing an exception, however, the resulting PDF won’t render. Perhaps it’s a shortcoming in my code, but I doubt it. My guess is if the component does work with memory streams, examples and documentation would be available. Additionally, iTextSharp doesn’t gracefully handle page breaks and content wrapping. For these two reasons, I didn’t go with iTextSharp.
UPDATE: Per a comment from Bruno Lowagie, it appears I was mistaken. One can generate a PDF in memory using iTextSharp. Bruno references his book for more information in his comment.
I didn’t spend as much time reviewing SharpPDF, Report.NET and NFop. This was primarily due to lack of documentation/examples to help with my evaluation. SharpPDF, an open-source PDF generator written entirely in C#, looks promising (it handles flowing paragraphs and tables from page to page) but I believe the effort has been somewhat abandoned since its last released was back in February 2005. In conjunction with this, I couldn’t come up with any samples or documentation (other than NDoc) and I was lead to believe SharpPDF handles PDF generation similarly to iTextSharp (reference to a physical file). In the long run, this SharpPDF probably wouldn’t have met my needs, but I would like to play with it a little.
AND THE WINNER IS…
In the end, I opted to go with Siberix Report Writer 6.0 which met every requirement with the exception of having a designer.
For a few days now, I’ve been working with the trial version (which is conveniently full-featured and simply applies a watermark to the generated report.) I was able to put a reporting framework in place relatively quickly. Of course, my reporting background definitely helped, but I was also able to find a working example for nearly everything I’ve needed to accomplish in the extensive set of Siberix samples.
On this note, if I were to make one request of Siberix, it would be for more samples which focus on report layout. They do provide one sample project which produces an invoice-like report, but since there is no designer, it would be great if more samples provided “templated” layouts.
The component isn’t free, but it’s close. It’s $299 (and the source can be purchased for $2000.) I haven’t had any issues with the product yet. In my opinion, it’s definitely worth the investment.
RESOURCE
I was lucky enough to come across a fine PDF Component for .NET write-up in the How-To-Select Guides series early on in the evaluation period. It provides a very extensive list of “everything PDF” from viewers to editors to print drivers. It’s worth a look.
I just took a look at SharpPDF. It’s got a method to render to a stream, so I believe that means you don’t need to write to a file. I agree that the NDoc only documentation is pretty bad, though.
You couldn’t help yourself. You just had to take a look. This is promising – if I encounter any issues with Siberix, I may give SharpPDF another look.
Let us know if you change your mind, need to work with dymnamic PDFs, too, soon
Cheers
Andy
Quick update. I think Siberix has some issues with the 64-bit version of the .NET framework. I have submitted a ticket to Siberix asking if this is a known limitation of their software.
Hi, I actually work for a company that has a product that sounds like it will do exactly what you are looking for. The name of the company is ceTe Software and the product you would need to use is DynamicPDF Generator for .NET, http://www.cete.com/Products/DynamicPDFForNET/. Following are the answers to your questions:
1. Yes, you can generate reports dynamically in memory and output it directly to the Web without requiring to physically create PDF file.
2. Using the DynamicPDF Generator for .NET it is possible to place the tables, text according to the available place on the PDF. You can add the extra text or records of a table which does not fit in a single page to a new page dynamically.
3. This product you can use in web as well as windows applications.
4. You can produce reports of various page sizes by specifying the size in the Page constructor and in Portrait and Landscape orientation. You can also use predefined page sizes included.
5. You can distribute for royalty free if you buy a Developer edition which allows one developer to develop the application and can distribute it for any number of clients. And we do have another licensing model, Server based licensing, which you can use for a single production server and any number of developers can work with that.
6. We have a very good documentation and a lot of examples on all topics and we provide a good supports also.
7. Yes the component has been in market since 2000 and following is the list to our customer list on our web site: http://www.cete.com/AboutUs/CustomerList.csp.
8. The new DynamicPDF ReportWriter product has a designer using which you can generate report layout very easily.
Thanks,
Ranga.
Ranga, This is a very nice overview. Thank you for the write-up. I have used DynamicPDF in the past and, if I recall, I liked the product. I’ll have to give it another look. Thanks again.
I’m sorry to hear that you didn’t succeed in generating a PDF in memory using iTextSharp. As a matter of fact you can write PDF to any OutputStream using iTextSharp. The examples all write to a physical file because that’s easy to test. (See chapter 1 of my book iText in Action) Please contact the iTextSharp mailing list if you want more info.
Thanks for the comment, Bruno. I’m happy to hear the short-coming was on my end. Can you correct me on the statement I made about page breaks too? I would love to know I incorrectly spoke to this as well.
I didn’t understand what you meant with that remark. If you add content, such as Paragraphs, Lists, Anchors,… (the objects described in chapter 4 of the book), a new page will be triggered automatically as soon as the page is full. Also: as soon as the page is full, it’s sent to the OutputStream, so that a lot of memory is freed (this is a problem with some other libraries; I use iText to create reports with 10,000+ pages; you shouldn’t keep that many pages in memory!).
Chapter 6 of the book deals with tables, and you’ll see there are different ways to split a table: should iText split a table between two rows, or can the rows be split? You can choose by setting some parameters. iText also supports repeating headers and footers in a table.
Then there’s chapter 7 that explains how you can gain full control over the distribution of content over different pages with ColumnText.
If you tried the .NET examples that can be found on different site, than I understand the problem: those examples are really old. But the book has new examples (in Java) that demonstrate how iText is meant to be used. Most of the examples can be easily adapted to C#.
And there’s always the mailing list
Thanks again, Bruno. I think you are correct regarding the older samples. There was a case where a table row which “fell” at the bottom on a page was vertically cut in half. This resulted in the top half of the row appearing on page A and the bottom half of the row appearing on page B. It sounds like this issue has been addressed as well, but I’m sure I was using the most recent release of the iTextSharp libraries.
By the way, I am now a proud subscriber to the mailing list. Many thanks.
Generation of the report to a file is better for me as we are trying to configure sending the report via email or online at user request. Why clutter up memory with this production when most DB’s are memory intensive and large user bases would drain the DB server unneccarily.
“Unfortunately, as best as I can tell, iTextSharp requires a physical file be generated.” that’s not true. It can be done without file, just on the fly. Look for an example in google.
private void makePdf()
{
// the PDF document itself;
Document doc = new Document();
HttpResponse rs = HttpContext.Current.Response;
rs.ContentType = “application/pdf”;
try
{
PdfWriter.GetInstance(doc, rs.OutputStream );
HeaderFooter header = new HeaderFooter(
new Phrase(
DateTime.UtcNow.ToString(“yyyy-MM-dd HH:mm:ss”) + ” GMT”,
new Font(Font.COURIER,
),
false
);
// top & bottom borders on by default
header.Border = Rectangle.NO_BORDER;
// center header
header.Alignment = 1;
// add header *before* opening document
doc.Header = header;
doc.Open();
Paragraph p = new Paragraph(“I have to prove better itextsharp “);
p.Alignment = 1;
doc.Add(p);
doc.Close();
}
catch { }
finally { if (doc != null) doc.Close(); }
}
@Jose – Thanks for the snippet.
In my asp.net application which converts html to pdf using itextsharp, i am facing one issue after creating pdf. In PDF , Some datagrid(its is html) are coming always in next page, Is there any sample code which splits datagrid rows across pdf pages instead of going to new page. Please help me its urgent for my application, If itextsharp doesnt not handle this issue then, is there any solution you have.. Pls help
Greetings from Carolina! I’m bored at work so I decided to browse your site on my iphone during lunch break. I love the knowledge you present here and can’t wait to take a look when I get home. I’m surprised at how quick your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyhow, very good site!
What is a good firefox addon to save massive number of pictures on separated links?
Nice post. Here’s a tool to use to create and publish your report online in minutes, without coding. You can create different graphs and layouts http://www.caspio.com/online-d.....ports.aspx