[
https://issues.apache.org/jira/browse/PDFBOX-3322?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16143822#comment-16143822
]
Nikita Gorbachevski commented on PDFBOX-3322:
---------------------------------------------
Relating scope of SignatureOptions to PDDocument to call their close methods in
a sequence is a very unclear behaviour which should be avoided. All fixes to
this problem that i've found [so
far|https://issues.apache.org/jira/browse/PDFBOX-3743] only modify javadocs and
examples but don't solve real issue. SignatureOptions should only perform job
according to its name - just store options. It shouldn't implement
AutoCloseable and parse any streams.
I would suggest not to call initFromRandomAccessRead() inside SignatureOptions
constructor and just store RandomAccessRead as a property. Then get reference
to RandomAccessRead in PDDocument#addSignature perform all necessary parsing of
RandomAccessRead in PDDocumen#prepareVisibleSignature and store reference to
visualSignature COSDocument as a property of PDDocument which will be closed
during PDDocument close method invocation. It will greatly simplify the code
base for clients. I think backward compatibility can be preserved storing both
new and old references in SignatureOptions for now marking old as deprecated.
Does it sound reasonable?
> 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
> Attachments: addSignatureFix.patch,
> 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.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]