if( pdfDocument.isEncrypted() )
{
DecryptDocument decryptor = new DecryptDocument( pdfDocument );
//Just try using the default password and move on
decryptor.decryptDocument( "" );
}
//create a tmp output stream with the size of the content.
ByteArrayOutputStream out = new ByteArrayOutputStream();
OutputStreamWriter writer = new OutputStreamWriter( out );