Hello Cristina, What PDFBox version are you using? Hopefully 2.0.18.
IMHO the problem is likely in your external signature server code, please compare it with the sign() code from the example.
Could you upload a result PDF to a sharehoster (do't attach)? Also try to run the ShowSignature.java example on your result PDF, I'd like to see the error message.
Tilman Am 09.02.2020 um 21:56 schrieb Cristina Ruica:
Hi! I'm trying to add external signature to a pdf, and I get formatting error when I open the document. My code is: <code> @Override public byte[] sign(InputStream content) throws IOException { try { MessageDigest digest = MessageDigest.getInstance("SHA-256"); byte[] hashBytes = digest.digest(content.readAllBytes()); String base64Hash = Base64.encodeBytes(hashBytes); String signature = (Base64signature from server) return Base64.decode(signature); } public void signDetached(PDDocument document, OutputStream output) throws IOException { PDSignature signature = new PDSignature(); signature.setFilter(PDSignature.FILTER_ADOBE_PPKLITE); signature.setSubFilter(PDSignature.SUBFILTER_ADBE_PKCS7_DETACHED); signature.setSignDate(Calendar.getInstance()); document.addSignature(signature); ExternalSigningSupport externalSigning = document.saveIncrementalForExternalSigning(output); byte[] cmsSignature = sign(externalSigning.getContent()); externalSigning.setSignature(cmsSignature); } </code>
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org For additional commands, e-mail: users-h...@pdfbox.apache.org