iText in Action: Covers iText 5

Category: Programming
Author: Bruno Lowagie
This Year Stack Overflow 2
This Month Stack Overflow 1


by anonymous   2017-08-20

Sorry, my first answer (since deleted -- FGITW answer saying just use iTextSharp) assumed it was PDF FAQ #1 when in fact it was PDF FAQ #~5, mea culpa...

There's no system-provided native PDF processing, so outside of using an app such as FoxIt or Acrobat -- which you shouldnt discount too quickly - people who use PDF will have one or the other and will be choosy about which one they prefer as they're not all equal, esp if you get into more advanced features and their associated licensing and monetisation schemes.

Not aware of any specific libraries that address this requirement, though the other question I've linked to above should have a good answer. ... researches; time passes... An answer on the other question says PDFSharp should suit, the sample looks straightforward.

On reflection based on looking at Pdfsharp's FAQ wiki, iTextSharp has similar stuff for generating TIFFs/images as PDFSharp has.

An alternative which may or may not be in scope is to generate and/or convert to e.g., an XPS file, which does have built in printing support (pretty sure .NET 3.5, and possibly earlier have it as a standard component in the Client Profile).

One point that shouldnt be missed in this all is that the Lowagie book (iText In Action) is excellent and if you're going to be doing anything in reading, writing or providing PDF forms, you should have it on your shelf. Similarly, if you do go the FLOSS library route, iText has to be seriously considered.

by anonymous   2017-08-20

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.


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.