1

With reference to this question Sign pdf asynchronously using digest. I am now doing exactly the same thing. I am trying to explore is there any new method to "save" the intermediate PDF object to database after getting the hash, and then load it from database again after I got the signed hash from somewhere, and then continue the PDF signing process.

(I notice that there is a similar operation using itext, which called deferred signing https://kb.itextpdf.com/home/it7kb/examples/digital-signatures-chapter-4, but I can't find similar reference for PDFBox.)

  • 1
    Did you see the "late external signing" comment in the CreateVisibleSignature examples? And see also https://github.com/crs2195/signature – Tilman Hausherr Jul 21 '20 at 15:03
  • I did study the CreateVisibleSignature example, also notice that there is a "isExternalSigning", and I also read as you mentioned. But what I want to find is to "save" the intermedia product to database after calling `ExternalSigningSupport externalSigning = document.saveIncrementalForExternalSigning(output);`, and then load it from database again later and continue. – Lawrence Leung Jul 22 '20 at 01:26
  • 1
    So your question is how to save a PDF to a database? You could use a ByteArrayOutputStream to save into, then extract the byte array (call toByteArray()) when done, then save this byte array into a blob field. – Tilman Hausherr Jul 22 '20 at 04:10
  • 1
    Indeed, either you can ask your database `Blob ` object for an `OutputStream` using `setBinaryStream(1)` and save there or you save to memory as proposed by @Tilman and store the whole byte array at once. – mkl Jul 22 '20 at 12:17
  • Sorry for my poor English. I mean that I want to save the "ExternalSigningSupport" to database, and then load it again to continue the process when I get the signed digest later. But this object can not be serialised. – Lawrence Leung Jul 22 '20 at 16:46
  • ExternalSigningSupport is a class, you don't want to save that. I suspect you want to save either the PDF or the hash or the signature. In all cases, these are byte arrays and these can be saved into a blob. If I didn't understand you, then bring up your implementation and show what is missing. – Tilman Hausherr Jul 23 '20 at 08:56

0 Answers0