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

Petras commented on PDFBOX-3322:
--------------------------------

I tried. If I close the options before _doc.saveIncremental(fis, fos)_ I get 
NPE in _RandomAccessFileInputStream_:
{code}
Exception in thread "main" org.apache.pdfbox.exceptions.COSVisitorException: 
java.lang.NullPointerException
        at 
org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1361)
        at org.apache.pdfbox.cos.COSStream.accept(COSStream.java:271)
        at org.apache.pdfbox.cos.COSObject.accept(COSObject.java:206)
        at 
org.apache.pdfbox.pdfwriter.COSWriter.doWriteObject(COSWriter.java:528)
        at org.apache.pdfbox.pdfwriter.COSWriter.doWriteBody(COSWriter.java:434)
        at 
org.apache.pdfbox.pdfwriter.COSWriter.visitFromDocument(COSWriter.java:1129)
        at org.apache.pdfbox.cos.COSDocument.accept(COSDocument.java:580)
        at org.apache.pdfbox.pdfwriter.COSWriter.write(COSWriter.java:1527)
        at 
org.apache.pdfbox.pdmodel.PDDocument.saveIncremental(PDDocument.java:1413)
        at 
org.apache.pdfbox.examples.signature.CreateSignature.signPDF(CreateSignature.java:136)
...
Caused by: java.lang.NullPointerException
        at 
org.apache.pdfbox.io.RandomAccessFileInputStream.read(RandomAccessFileInputStream.java:94)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
        at 
org.apache.pdfbox.pdfwriter.COSWriter.visitFromStream(COSWriter.java:1344)
        ... 16 more
{code}

P.S. I used modified _CreateSignature_ example adapted to use BC v1.52, 
therefore _CreateSignature.signPDF_ line number in trace is different.

> Warning "You did not close a PDF Document" when visual signature is added
> -------------------------------------------------------------------------
>
>                 Key: PDFBOX-3322
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-3322
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: PDModel, Signing
>    Affects Versions: 1.8.11
>            Reporter: Petras
>            Assignee: Tilman Hausherr
>              Labels: signature
>             Fix For: 1.8.13
>
>         Attachments: PDFBOX_3322_VisualSignatureClosing.patch
>
>
> When visual signature is added, warning "You did not close a PDF Document" is 
> added to the output log. It appears, that _VisualSignatureParser_ creates an 
> instance of _COSDocument_ and later is held by _SignatureOptions_, but for 
> this instance the {{#close()}} method is never called, which results to that 
> warning reported by its {{#finalize()}} method.
> Probably it should by closed by _PDDocument_ when used after signing.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to