pdfbox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrea Vacondio (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PDFBOX-807) NullPointerException in StandardSecurityHandler.java:261
Date Tue, 30 Aug 2011 12:09:37 GMT

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

Andrea Vacondio commented on PDFBOX-807:
----------------------------------------

I attached an encrypted document with owner password "test". Using PDFBox 1.6.0 I created
a simple test:

public void testDec() throws Exception {

        String[] args = { "-password", "test",
                "/tmp/enc_test_test_file.pdf",
                "/tmp/out.pdf" };
        Decrypt.main(args);
    }

And I got the following stacktrace:
java.lang.NullPointerException
	at org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.prepareDocumentForEncryption(StandardSecurityHandler.java:283)
	at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1306)
	at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1121)
	at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1102)
	at org.apache.pdfbox.Decrypt.decrypt(Decrypt.java:153)
	at org.apache.pdfbox.Decrypt.main(Decrypt.java:57)
	........


> 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: Adam Nichols
>            Priority: Blocker
>         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.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message