开发者

Can I reset a forgotten owner password with iText?

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?


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜