Was the file password protected before you started? There's a method to remove all encryption (I think it's in PDDocument, if I recall correctly). If you start with that method, you can be certain that any old encryption was removed, and all that will remain is what is in your code below.

On 09/16/2011 09:00 AM, [email protected] wrote:
I am using the code below to semi-protect the generated PDFs, hundreds of
these are being generated but in the past three months I have (just) two
instances where the PDF cannot be opened (in adobe or pdfxchange) because
it prompts for a password.


-----------------------------------------------------------------
         public void lockDown(String owner_pwd) throws
BadSecurityHandlerException {
                 AccessPermission ap =
document.getCurrentAccessPermission();
                 logger.info("locking down  ");
                 ap.setCanModify(false);
                 ap.setCanAssembleDocument(false);
                 ap.setCanExtractContent(false);
                 ap.setCanFillInForm(false);
                 ap.setCanModifyAnnotations(false);
                 ap.setReadOnly();
                 StandardProtectionPolicy policy = new
StandardProtectionPolicy(owner_pwd, null, ap);
                 //policy.
                 document.protect(policy);
                 logger.info("locked");
         }
-----------------------------------------------------------------

I'm failrly sure (though I could be wrong) that the application is not
responsible for, as you can see, the user password is hard-coded and null.

Any ideas

Steve Lindsey


Reply via email to