1.

Why Do I Get A “warning: You Did Not Close The Pdf Document”?

Answer»

You need to call close() on the PDDocument INSIDE the finally block, if you don’t then the document will not be closed PROPERLY. Also, you must close all PDDocument objects that get created. The following code creates two PDDocument objects; ONE from the “new PDDocument()” and the second by the LOAD method.

PDDocument doc = new PDDocument();
try
{
doc = PDDocument.load( "my.pdf" );
}
finally
{
if( doc != NULL )
{
doc.close();
}
}

You need to call close() on the PDDocument inside the finally block, if you don’t then the document will not be closed properly. Also, you must close all PDDocument objects that get created. The following code creates two PDDocument objects; one from the “new PDDocument()” and the second by the load method.

PDDocument doc = new PDDocument();
try
{
doc = PDDocument.load( "my.pdf" );
}
finally
{
if( doc != null )
{
doc.close();
}
}



Discussion

No Comment Found