private PDDocument encrypt(int keyLength, int sizePriorToEncr,
PDDocument doc, String prefix, AccessPermission permission,
boolean nonSeq, String userpassword, String ownerpassword) throws IOException
{
AccessPermission ap = new AccessPermission();
StandardProtectionPolicy spp = new StandardProtectionPolicy(ownerpassword, userpassword, ap);
spp.setEncryptionKeyLength(keyLength);
spp.setPermissions(permission);
doc.protect(spp);
File pdfFile = new File(testResultsDir, prefix + keyLength + "-bit-encrypted.pdf");
doc.save(pdfFile);