[ https://issues.apache.org/jira/browse/PDFBOX-2719?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14371537#comment-14371537 ]
Maruan Sahyoun commented on PDFBOX-2719: ---------------------------------------- looking at {{addSignature(PDSignature sigObject, SignatureInterface signatureInterface)}} this calls {{addSignature(PDSignature sigObject, SignatureInterface signatureInterface, SignatureOptions options)}} with a {{new SignatureOptions()}} object. In there the default page number is set to {{1}}. So I think we have to change the default page number in {{SignatureOptions()}} too as {{catalog.getPages().get(startIndex)}} is zero-based. [~cbremaud] would you have a small test case to validate the changes. > The addSignature() method always set the visual signature on the last page of > the PDF > ------------------------------------------------------------------------------------- > > Key: PDFBOX-2719 > URL: https://issues.apache.org/jira/browse/PDFBOX-2719 > Project: PDFBox > Issue Type: Bug > Components: Signing > Affects Versions: 2.0.0 > Reporter: Cyril Bremaud > Labels: easyfix > > The {{addSignature()}} method always set the visual signature on the last > page of the PDF. > This is certainly due to the following lines in {{PDDocument}} class : > {code:title=PDDocument.java|borderStyle=solid} > ... > int startIndex = Math.max(Math.min(options.getPage(), 0), pageCount - 1); > PDPage page = catalog.getPages().get(startIndex); > ... > {code} > I think {{Math.min}} and {{Math.max}} have been inverted. -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@pdfbox.apache.org For additional commands, e-mail: dev-h...@pdfbox.apache.org