[
https://issues.apache.org/jira/browse/PDFBOX-5067?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17258710#comment-17258710
]
Tilman Hausherr commented on PDFBOX-5067:
-----------------------------------------
Resources should be closed in the method that opens them. The method
calculatePageSizeFromFile is used in the class and is now public in the class
and no longer closed. This is confusing. PDVisibleSignDesigner and the related
classes are notoriously difficult to use and I don't want to create more
problems there. In many years, nobody was able to come up with text signature
code, which is why CreateVisibleSignature2.java was created. If you use that
example as a starting point, then you shouldn't use PDVisibleSignDesigner at
all. Instead, copy what you need, which is calculatePageSize.
Your change of calculatePageSizeFromFile also violates the "do one thing"
principle, because it changes something and returns something. (Yes, we likely
have many violations of the D1T principle, but we should avoid to have more)
> make PDVisibleSignDesigner memory aware
> ---------------------------------------
>
> Key: PDFBOX-5067
> URL: https://issues.apache.org/jira/browse/PDFBOX-5067
> Project: PDFBox
> Issue Type: Improvement
> Components: Signing
> Affects Versions: 2.0.23
> Reporter: Ralf Hauser
> Priority: Major
> Attachments: patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
> MemoryUsageSetting.setupMixed(15000000)
> to limit the memory usage of PDDocument document to 15 MB in
> CreateVisibleSignature in
>
> a) setVisibleSignDesigner() and used the now memory-aware constructor of
> PDVisibleSignDesigner
> and
> b) in signPDF(), reused PDDocument
> setTsaUrl(tsaUrl);
> PDDocument doc = null;
> if (null != visibleSignDesigner) {
> doc = visibleSignDesigner.getDocument();
> }
> if (null == doc) {
> doc = Loader.loadPDF(inputFile, memoryUsageSetting);
> }
> // creating output document and prepare the IO streams.
> ...
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]