You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Ling Hock Hin, Daniel (Jira)" <ji...@apache.org> on 2021/02/04 09:10:00 UTC
[jira] [Created] (PDFBOX-5096) Is there a way for PDFBox to decrypt
encrypted pdf files without providing the password?
Ling Hock Hin, Daniel created PDFBOX-5096:
---------------------------------------------
Summary: Is there a way for PDFBox to decrypt encrypted pdf files without providing the password?
Key: PDFBOX-5096
URL: https://issues.apache.org/jira/browse/PDFBOX-5096
Project: PDFBox
Issue Type: Wish
Reporter: Ling Hock Hin, Daniel
My application needs to remove metadata of pdf files when uploaded. When attempting to load and remove metadata of encrypted pdf files, I get the logs below.
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_275]Caused by: java.lang.IllegalStateException: PDF contains an encryption dictionary, please remove it with setAllSecurityToBeRemoved() or set a protection policy with protect() at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1367) ~[pdfbox-2.0.22.jar:2.0.22] at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1319) ~[pdfbox-2.0.22.jar:2.0.22] at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1357) ~[pdfbox-2.0.22.jar:2.0.22]
Tried to use the code below but it does not seem to work.
PDDocument document = PDDocument.load(documentBytes);
if (document.isEncrypted()) {
document.setAllSecurityToBeRemoved(true);
}
Appreciate your advice.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org