Home
iTextSharp
iText in Action, 2nd Edition Webified iTextSharp Examples
The Book
iText in Action, Second Edition was released in October 2010. Get the Java source code for the examples.
Webified iTextSharp Examples, Updated 2011-08-27
Examples updated to run with iTextSharp 5.1.2. 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 Close() calls.
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.
Some notes:
- Skipped Chapter 12. Hopefully someday I'll get around to adding some examples. Unfortuately I don't get a chance to use iTextSharp anymore at work. At my previous job I was mainly a developer. But I accepted a job in May 2011 and now I'm responsible for a larger breadth of duties; Microsoft SharePoint, Server, and SQL Server, to name a few. What I will do is try and keep what is on this site updated. On the bright side, I'm working in Germany, not in the states :)
- 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 ~/bin:
- iTextSharp, including iTextAsian.dll. (under "extras") 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 Saturday, August 27, 2011 at 10:19 GMT.
SHA1 Hash: ceb74d146ac9f87055120cff0c84918a77ccbfc3
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
Chapter01: Introduction
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
Chapter13: Protect your PDF
Chapter14: PDF files inside-out
- DirectorCharts not converted from book example.
- GetContentStream
- Graphics2DFonts not converted from book example.
- GraphicsStateOperators
- PathConstructionAndPainting
- 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.
- TextMethods
- TextStateOperators
- TransformationMatrix1
- TransformationMatrix2
- TransformationMatrix3
Chapter15: The imaging model
Chapter16: Marked content and parsing PDF