I see.  I haven't done any PDF generation, but I think you'd have to
take a look at the specific function calls for those particular PDFs.
Can you reproduce the issue consistently?  It'd help you track it down
if you can provide the same inputs as production and then check at
various points to determine where the security is getting triggered.

As a short-term workaround, give the setAllSecurityToBeRemoved(true)
method (see PDFBOX-526) a try right before you encrypt it, and then
see if that works.  I'm fairly certain it will.  It's not the best
solution, but it should be the quickest one.

On Mon, Sep 19, 2011 at 5:01 AM,  <[email protected]> wrote:
> Hi, thanks for the reply.
>
> These are new files, ie, i'm creating them from a memory structure using
> Apache FOP (legacy code), PDFBox was added recently to post-process the
> documents in order to make them read-only .
>
> The crucial point is that all of the pdfs (200-300 per day) are created
> and locked down in the same way and yet in the last couple of months I've
> had two instances of a file being password protected at the user level.
>
> Steve Lindsey
>
>
>
>
>
>
>
>
>
>
>
> Adam Nichols <[email protected]>
> 16/09/2011 17:15
> Please respond to
> [email protected]
>
> To
> [email protected]
> cc
>
> Subject
> Re: PDF is wrongly password protected
>
>
>
>
>
>
> 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