[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-08 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5067:
-

Done. I'm not really happy with it. It's kindof weird that the file parameter 
is passed to sign() but is ignored if it was passed earlier.

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.a.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.b.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-08 Thread ASF subversion and git services (Jira)


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

ASF subversion and git services commented on PDFBOX-5067:
-

Commit 1885270 from Tilman Hausherr in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1885270 ]

PDFBOX-5067: open PDF file only once, as suggested by Ralf Hauser

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.a.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.b.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-08 Thread Ralf Hauser (Jira)


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

Ralf Hauser commented on PDFBOX-5067:
-

Hope the closeQuietly() line fills the gap with 
[^patch_PDFBOX-5067_CreateVisibleSignature.b.txt] .

 

If it really was only that one line, I happily encourage you to just add it or 
similar minor things in the future without getting back to me.

([https://svn.apache.org/r1885267]  after all still ignores the valuable 
suggestion of [~msahyoun] )

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.a.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.b.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-08 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5067:
-

I committed only a part of it - your proposed code doesn't close the PDDocument 
object.

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.a.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-08 Thread ASF subversion and git services (Jira)


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

ASF subversion and git services commented on PDFBOX-5067:
-

Commit 1885267 from Tilman Hausherr in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1885267 ]

PDFBOX-5067: allow the passing of a MemoryUsageSetting, as suggested by Ralf 
Hauser

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.a.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-07 Thread Ralf Hauser (Jira)


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

Ralf Hauser commented on PDFBOX-5067:
-

Sorry, the 2nd use "doc" was forgotten - now it is there and should accelerate 
the execution [^patch5067_CreateVisibleSignature.txt]

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt, 
> patch_PDFBOX-5067_CreateVisibleSignature.a.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-07 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5067:
-

I looked at this and I don't get it - you load it into a local field "doc" and 
then do nothing with that one. (The old code isn't much better because in both 
cases, the file to be signed is opened twice) And while looking at this, I'm 
wondering why the "setVisibleSignDesigner" methods are all public. It makes no 
sense unless the author had bigger plans, e.g. passing a different file than 
the one to sign.

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-06 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5067:
-

OK I'll do that (tonight or tomorrow).

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-06 Thread Ralf Hauser (Jira)


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

Ralf Hauser commented on PDFBOX-5067:
-

[~tilman], I tend to make fields protected to facilitate sub-classing. But if 
you prefer them being private, go for it!

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-06 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5067:
-

Why must the two fields be protected? CreateVisibleSignature.java isn't meant 
as part of the library, it is a source code example for people to create their 
own signing tool. Some parts may not be useful for all users, e.g. certify.

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-05 Thread Ralf Hauser (Jira)


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

Ralf Hauser commented on PDFBOX-5067:
-

[~msahyoun] thanks for the hint! This would be used as described in 
[^patch5067_CreateVisibleSignature.txt]

> 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: patch5067_CreateVisibleSignature.txt, 
> patch_PDFBOX-2512.txt, patch_PDFBOX-5067.txt
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-05 Thread Maruan Sahyoun (Jira)


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

Maruan Sahyoun commented on PDFBOX-5067:


[~hau...@acm.org] why not use {{PDVisibleSignDesigner(PDDocument document, 
BufferedImage image, int page)}} which allows to pass the document?

> 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(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-04 Thread Tilman Hausherr (Jira)


[ 
https://issues.apache.org/jira/browse/PDFBOX-5067?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-04 Thread Ralf Hauser (Jira)


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

Ralf Hauser commented on PDFBOX-5067:
-

You say "... _returns a PDDocument, which is then partly lost_"

 

What is the problem with that ?

It is the decision of the user of PDVisibleSignDesigner whether to "loose" the 
PDDocument or reuse it with benefits.

For example, in CreateVisibleSignature1.java I can use it with significant 
speed/memory benefits, with CreateVisibleSignature2.java it will be ignored (it 
has been allocated in memory anyway, the change extends the lifetime in memory 
in the latter case only for microseconds).

Is it really a problem to "empower" the end-user/-programmer in this way by 
making one version of the method "public"?

> 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(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-04 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5067:
-

No, calculatePageSizeFromFile now exists twice, once returns nothing and once 
(and public???) returns a PDDocument, which is then partly lost.

> 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(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-03 Thread Ralf Hauser (Jira)


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

Ralf Hauser commented on PDFBOX-5067:
-

Thanks for the commit of the "uncontroversial".

Tried to make the 2nd half also acceptable with [^patch_PDFBOX-5067.txt]

What do you think ?

> 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(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-03 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5067:
-

I wanted to commit the "uncontroversial" parts before the new year "inbox 
madness" at works starts. Does this help?

> 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
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-03 Thread ASF subversion and git services (Jira)


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

ASF subversion and git services commented on PDFBOX-5067:
-

Commit 1885091 from Tilman Hausherr in branch 'pdfbox/trunk'
[ https://svn.apache.org/r1885091 ]

PDFBOX-5067: allow the passing of a MemoryUsageSetting, as suggested by Ralf 
Hauser

> 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
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-03 Thread Ralf Hauser (Jira)


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

Ralf Hauser commented on PDFBOX-5067:
-

Thanks for the feedback

 

I tested it on the basis of CreateVisibleSignature2.java ( also with setupMixed 
15MB )

It needed 8 MB more Xmx (==> 69m). But PDDocument was only loaded once, so in 
this case, the getter is not used. Although when you close 
PDVisibleSignDesigner it would be deallocated anyway.

 

> Some of the constructors set that field, some don't (the one that calls 
> {{calculatePageSizeFromStream}})
I only added it where the test did a Loader.loadPDF() - there may well be more 
places it could be added. But still, I assume it is quicker and not that worse 
for the memory if the load only happens once.

> 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
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org



[jira] [Commented] (PDFBOX-5067) make PDVisibleSignDesigner memory aware

2021-01-03 Thread Tilman Hausherr (Jira)


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

Tilman Hausherr commented on PDFBOX-5067:
-

- The old PDVisibleSignDesigner should call the new one to avoid double code
- The new field should be on top
- Why the new "PDDocument" field? You're exposing internals, and this prevents 
closing of the document.
- Some of the constructors set that field, some don't (the one that calls 
{{calculatePageSizeFromStream}})

Why not use the CreateVisibleSignature2.java as starting point? This is easier 
to understand.

> 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
>
>
> PDFBOX-2512 might have failed earlier if I hadn't used
>   MemoryUsageSetting.setupMixed(1500)
> 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: dev-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: dev-h...@pdfbox.apache.org