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

Michael Klink commented on PDFBOX-5717:
---------------------------------------

PDFBox has a problem with object 3 - in the catalog it is referred to as name 
tree base for JavaScript:

{code}
4
0
obj
<<
/Type
/Catalog
/Names
<<
/JavaScript
3
0
R
>>
...
{code}

But there is no object 3 in the file:

{code}
xref
0 246
0000000002 65535 f 
0002000782 00000 n 
0000000003 00000 f 
0000000000 00000 f 
...
{code}

According to the spec, PDFBox should treat this as a {{null}} object:

{quote}
An indirect reference to an undefined object shall not be considered an error 
by a PDF processor; it shall be treated as a reference to the null object.
{quote}

Unfortunately it doesn't:

{code}
Thread [main] (Suspended (exception NullPointerException))      
        owns: Hashtable<K,V>  (id=64)   
        Hashtable<K,V>.computeIfAbsent(K, Function<? super K,? extends V>) 
line: 1032   
        COSWriter.getObjectKey(COSBase) line: 1089      
        COSWriter.writeReference(COSBase) line: 1367    
        COSWriter.visitFromDictionary(COSDictionary) line: 1207 
        COSWriter.writeDictionary(COSDictionary) line: 1155     
        COSWriter.visitFromDictionary(COSDictionary) line: 1202 
        COSDictionary.accept(ICOSVisitor) line: 1265    
        COSWriter.doWriteObject(COSObjectKey, COSBase) line: 610        
        COSWriter.doWriteObject(COSBase) line: 643      
        COSWriter.doWriteObjects() line: 540    
        COSWriter.doWriteBody(COSDocument) line: 450    
        COSWriter.visitFromDocument(COSDocument) line: 1299     
        COSDocument.accept(ICOSVisitor) line: 413       
        COSWriter.write(PDDocument, SignatureInterface) line: 1568      
        COSWriter.write(PDDocument) line: 1444  
        PDDocument.saveIncrementalForExternalSigning(OutputStream) line: 1186   
{code}

> NullPointerException calling saveIncrementalForExternalSigning
> --------------------------------------------------------------
>
>                 Key: PDFBOX-5717
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-5717
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Signing
>    Affects Versions: 3.0.0 PDFBox
>            Reporter: Daniele Ribaudo
>            Priority: Major
>         Attachments: 
> Cryptomathic_White_Paper_-_eIDAS_Compliant_Remote_eSigning.pdf
>
>
> I tried to apply a digital signature to the attached PDF using the method 
> PDDocument.saveIncrementalForExternalSigning in the release 3.0.0 of PDFBox 
> but a NPE is thrown every time.
> The same action executed on a 2.0.x release is successfully completed.
> Here you are a snipped code to reproduce the error:
>    
> {code:java}
> PDDocument document = Loader.loadPDF(new 
> File("Cryptomathic_White_Paper_-_eIDAS_Compliant_Remote_eSigning.pdf"));
> document.addSignature(new PDSignature(), new SignatureOptions());
> ExternalSigningSupport externalSigning = 
> document.saveIncrementalForExternalSigning(new ByteArrayOutputStream());
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org

Reply via email to