Playing with the code in Visual Studio and taking advantage of IntelliSense I looked at the various possible methods on the Document
object. I saw that there is an additional method called CloseDocument()
, so I changed this line:
doc.Close();
to
doc.CloseDocument();
and guess what? The thing started working again. No more exceptions. Awesome!
Hope it helps anyone that might encounter this same issue in the future...
Well well well... after trying different input options I started getting the exception again...
I was explicitly calling:
pdfReader.Close();
inside an AppendToDocument
method. This was happening before calling doc.Close();
. Just commented the above line and the exception went away.