You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Andreas Lehmkühler (JIRA)" <ji...@apache.org> on 2012/05/19 19:13:41 UTC
[jira] [Resolved] (PDFBOX-807) NullPointerException in
StandardSecurityHandler.java:261
[ https://issues.apache.org/jira/browse/PDFBOX-807?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andreas Lehmkühler resolved PDFBOX-807.
---------------------------------------
Resolution: Fixed
Fix Version/s: 1.7.0
Assignee: Andreas Lehmkühler (was: Adam Nichols)
As Adam already mentioned. I just added a call of PDDocument#setAllSecurityToBeRemoved(true) before saving the pdf to the Decrypt class in revision 1340517.
This was easy to solve as Adam already did all the work.
> NullPointerException in StandardSecurityHandler.java:261
> --------------------------------------------------------
>
> Key: PDFBOX-807
> URL: https://issues.apache.org/jira/browse/PDFBOX-807
> Project: PDFBox
> Issue Type: Bug
> Components: PDModel
> Affects Versions: 1.2.1
> Environment: JDK 1.6.0_21, Windows XP 32 Bit.
> Reporter: MH
> Assignee: Andreas Lehmkühler
> Priority: Blocker
> Fix For: 1.7.0
>
> Attachments: enc_test_test_file.pdf
>
>
> I like to add text to a PDF and used the example code AddMessageToEachPage.java to do this. I added decryption to support encrypted docs:
> doc = PDDocument.load(sourceFile);
> if (doc.isEncrypted()) {
> doc.decrypt(ownerPwd);
> }
> When my document is encrypted, the decryption succeeds without error message, but for such encrypted docs, when callinf doc.save(), a NullPointerException occurs:
> -----------------------------------------
> java.lang.NullPointerException
> at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.prepareDocumentForEncryption(StandardSecurityHandler.java:261)
> at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1013)
> at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:911)
> at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:892)
> -----------------------------------------------------------------
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira