iText in Action, Second Edition was released in October 2010. Get the Java source code for the examples.
Webified iTextSharp Examples, Updated 2012-03-26
Examples updated to run with iTextSharp 184.108.40.206. Since version 5.0.6 iTextSharp supports the IDisposable interface for classes that implement the IDocListener interface or inherit from the PdfStamper class. So if you prefer, creating a PDF is now a four-step process - just add a using statement and you can forget all those
When I started this, the examples actually ran on this web server, but no longer. However they will run as a web project on your local machine using Visual Studio. The source code also now includes a simple command line executable to build the result files for people who don't do web development.
- Skipped most of Chapter 12. Hopefully I'll get around to adding more examples someday. Unfortuately, I don't get to use iTextSharp at work anymore. I've always been a web developer, until accepting a job in May 2011 and am now in a position of what amounts to a developer black hole. What I will do is try and keep what is on this site updated.
- There are a lot of examples missing from Chapter 14. The reason is that iTextSharp does not implement the Java Graphics2D class.
The examples are converted to
C# from the Java book examples and developed with ASP.NET 3.5, so your mileage may vary. The source code includes all the classes needed to run the examples, as well as the HTTP Handler to stream the PDF to the web client. However, you DO need to download the following .dlls from the following web sites and copy them to
- iTextSharp, including iTextAsian.dll, which is under "extras" and was updated to version 220.127.116.11 when iTextSharp 18.104.22.168 was released. As announced in the 5.1.0 changelog, the RichMedia dictionaries have been moved to a separate namespace/.dll. In other words, the itextsharp.xtra.dll is required for the Chapter 16 examples.
- System.Data.SQLite - in summer 2011 the core SQLite team themselves have taken over the project from the original developer. (database file included with source code)
- DotNetZip. I got tired of keeping track of all the files for some examples, by packing them together it's easier. (for me) You can use the Ionic.Zip.Reduced.dll.
Get the zipped source code from Google docs, last updated Monday, March 26, 2012 at 13:55 GMT. And yes I'm using a URL shortener, which some people might not like, but it's easier for me to track that way.
SHA1 Hash: acd4f949457bfe0ab340d1dd948c0b99597459bf
This page is not included with the source code, that's an exercise left for the reader.
Chapter Source Code
KuujinboWeb: Web Project Helper Classes (NOT part of book examples)
Intro_1_2: Filmfestival POJOs/Database Access
Chapter02: Composing a document using iText's Basic Building Blocks
Chapter03: Adding content at absolute positions
Chapter04: Organizing content in tables
Chapter05: Completing your layout using page and table events
Chapter06: Working with existing PDFs
Chapter07: Making documents interactive
Chapter08: Filling out forms
Chapter09: Integrate iText in your web applications
Chapter10: Brighten up your PDF with images and color
Chapter11: Choose the right font
Chapter12: Protect your PDF
- EncryptWithCertificate not converted from book example.
- SignatureExternalHash not converted from book example.
- SignatureField not converted from book example.
- Signatures not converted from book example.
- SignWithBC not converted from book example.
- TimestampOCSP not converted from book example.
Chapter13: PDF files inside-out
Chapter14: The imaging model
- DirectorCharts not converted from book example.
- Graphics2DFonts not converted from book example.
- PearExample not converted from book example.
- PearToPdf not converted from book example.
- Text1ToPdf1 not converted from book example.
- Text1ToPdf2 not converted from book example.
- Text2ToPdf1 not converted from book example.
- Text2ToPdf2 not converted from book example.
- Text2ToPdf3 not converted from book example.
- Text3ToPdf not converted from book example.
- Text4ToPdf not converted from book example.
- TextExample1 not converted from book example.
- TextExample2 not converted from book example.
- TextExample3 not converted from book example.
- TextExample4 not converted from book example.
Chapter15: Marked content and parsing PDF
Chapter16: PDF streams