* @param doc The document to attempt to decrypt.
* @param password The password to attempt to decrypt.
* @return True if successful */
private boolean tryDecrypt(PDDocument doc, String password) {
try {
DecryptionMaterial m = new StandardDecryptionMaterial(password);
doc.openProtection(m);
return true;
} catch (BadSecurityHandlerException ex) {
return false;
} catch (CryptographyException ex) {