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

Julian Isaac commented on PDFBOX-4346:
--------------------------------------

Thanks for the reply. Sorry, the PDF contains private information so can't be 
posted on a public forum. However, I did re-try with the 2.0.12 version of 
PDFBox and got the following different exception:

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:1310)
    at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1262)
    at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1295)
    at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1266)
    at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1254)
    at my.modules.utils.MetaDataUpdater.save(MetaDataUpdater.java:146)

 

So I think that gives a pretty good idea what it is about the specific PDFs 
that causes the NPE to occur on saving in the 1.8 series of PDFBox?

And finally, thanks for the tip about loadNonSeq(), will give it a try and 
report back...

> NPE on calling save()
> ---------------------
>
>                 Key: PDFBOX-4346
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4346
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 1.8.10, 1.8.16
>            Reporter: Julian Isaac
>            Priority: Major
>
> Opening a PDF file, making some changes to the metadata (set Producer, 
> Creator), then calling save(String fileName) results in null pointer 
> exception (on some PDFs).
> java.lang.NullPointerException
>  at org.apache.pdfbox.pdmodel.PDPageNode.updateCount(PDPageNode.java:100)
>  at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1364)
>  at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1350)
>  at org.apache.pdfbox.pdmodel.PDDocument.save(PDDocument.java:1337)
>  at my.modules.utils.MetaDataUpdater.save(MetaDataUpdater.java:146)
> It's a maven project and the version of PDFBox I'm using is 1.8.16. I'm 
> trying to save back to the same file as the one I've opened...
> Not sure why it's trying to update the page count when all I'm changing is 
> the metadata?
> Seems this returns null which means the page instance variable is null, 
> resulting in the NPE when page.setLong() is called...
>     public PDPageNode getPages()
>     {
>         return new PDPageNode( (COSDictionary)root.getDictionaryObject( 
> COSName.PAGES ) );
>     }



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to