You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Tilman Hausherr (Jira)" <ji...@apache.org> on 2021/02/05 05:23:00 UTC

[jira] [Comment Edited] (PDFBOX-5096) Is there a way for PDFBox to decrypt encrypted pdf files without providing the password?

    [ https://issues.apache.org/jira/browse/PDFBOX-5096?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17279342#comment-17279342 ] 

Tilman Hausherr edited comment on PDFBOX-5096 at 2/5/21, 5:22 AM:
------------------------------------------------------------------

What happened when you did use it? Please share your PDF and the smallest code that reproduces the problem. 

"but it does not seem to work" is not a good description of a problem.


was (Author: tilman):
What happened when you did use it? Please share your PDF and the smallest code that reproduce the problem. "but it does not seem to work" is not a good description of a problem.

> 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
>            Priority: Major
>
> 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