tags:

views:

260

answers:

3

With iText I can use Java to open a pdf and write it. If the pdf has an owner password I can still open it but it can not be written.

Clearly the content is readable, it seems like at that point you could simply write the document to a new file. iText doesn't allow this, it throws a bad password exception. Is there a way around this?

A: 

It sounds like the PDF is likely encrypted and has an owner password set but no user password set. If that's the case then iText is doing the right thing, since the owner password must be supplied in order to decrypt the file before you write the document to a new file (by contrast supplying just the user password, in this case nothing, will allow you to view the PDF and sometimes perform other operations on it like printing and copy/paste).

Most, if not all, well reputed toolkits are going to respect the encryption. However there are some less scrupulous tools out there that allow passwords to be "broken off." This is generally best avoided but such tools do exist.

The other option, assuming that the document's permissions have been set so that the user password allows printing, would be to print the PDF to a new PDF, either using a printer driver based conversion SDK (if you get a lot of these files) or by simply manually printing (if you only get them once in a blue moon). Printing a PDF to another PDF is a somewhat nsaty process because you then have to take care to manage instances of Acrobat, but can be done in a limited fashion if absolutely necessary.

yu-chen-pdfonline-com
You are correct, owner password but no user pasword. The point I'm asking about is if once the doc is open, can the owner password be bypassed to save as a different PDF. It seems like the answer is basically 'Yes but you shouldn't do it'
Tom Hubbard
A: 

By removing the throw of BadPasswordException I was able to successfully save a pdf that had an owner password.

Tom Hubbard
A: 

what do you do when your itext is on--RECE--??? and how do you reset it??

myra
I'm not sure what RECE is. Could you elaborate?
Tom Hubbard