iTextSharp frustrations
I’ve been working a lot with iTextSharp lately. It’s incredibly useful but also sparsely documented, and the design concept is far from obvious. Here’s what I mean.
You don’t instantiate a PdfDocument. even though its constructor is public. You instantiate a Document. It creates a PdfDocument behind your back.
“New Page” behavior is extra bewildering!
If you haven’t put anything onto a page, but call PdfWriter.NewPage(), you will not get a new page.
You can override this behavior by setting PdfWriter.PageEmpty to false. (You can’t set it to true!)
Guess what? Pulling the drawing context so you can position text by the pixel, and then doing so, doesn’t count as putting anything on the page.
Sigh.