When signing using PKCS7 or PAdes with a timestamp server, you might receive the following exception:

com.qoppa.pdf.PDFException: Signature hash (7895 bytes) will not fit in allotted space (7500 bytes).Increase timestamp server length estimate.

To resolve this issue, you can increase the length estimate when defining the timestampserver parameters (the default length is originally set to 5500 bytes). This length parameter is used for padding of the digital signature entry in the PDF document.

// increase timestamp server signature size to 7500
TimeStampServer.setLengthEstimate(7500);