Dispose of itextSharp objects

I want to get rid of the itextsharp, PdfWriter, Font Color document, which will be deleted explicitly. Can someone please tell me how to achieve the same.

+3
source share
1 answer

I just looked through some code (had a couple of minutes). It looks like PdfWriter implements IDisposable (or at least the IDocListener, which, if you go far down, inherits PdfWriter). You just need to call Dispose () (or wrap it in a using statement):

using(PdfWriter MyWriter=PdfWriter.GetInstance(Document,Stream))
{
...
}

The same with most of the rest (Document, etc.). Although this only looks like newer versions (version 4.0 in one of my projects doesn't seem to use IDisposable for PdfWriter, etc.)

+1
source

All Articles