I want to dispose itextsharp document, PdfWriter, Font Color objects to be disposed explicitly. Can anyone please tell me how to achieve the same.
I just looked through some code (had a free couple of minutes). It looks like PdfWriter implements IDisposable (or at least IDocListener does, which if you go far enough down, PdfWriter inherits from). You should just be able to call Dispose() (or wrap it in a using statement):
using(PdfWriter MyWriter=PdfWriter.GetInstance(Document,Stream))
{
...
}
Same with most everything else (Document, etc.). Although that seems to be only with newer versions (the 4.0 version in one of my projects doesn't seem to use IDisposable for PdfWriter, etc.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With