Hi,

here's code for extracting hash from signature :

             // core aspect of PDF signatures :
             // signatures are made by a special / partial hash
             MessageDigest messageDigest = MessageDigest.getInstance( 
getDocumentHashAlgorithm() );
             byte read_buf[] = new byte[ hashBufferSize ];
             int n;
             InputStream inp = sap.getRangeStream();
             while ( ( n = inp.read( read_buf ) ) > 0) {
                 messageDigest.update( read_buf, 0, n );
             }
             byte pdf_hash[] = messageDigest.digest();

Replacing the existing signature content is easy as I created it upfront with 
well known content, big enough to hold the hex-coded signature. Once the 
signature is ready, it's a simple find'n'replace method on the PDF file.

Greetings

Andreas

--
Andreas Kühne phone: +49 177 293 24 97 mailto: [email protected]

Trustable Ltd. Niederlassung Deutschland Ströverstr. 18 - 59427 Unna 
Amtsgericht Hamm HRB 5868

Directors Andreas Kühne Heiko Veit

Company UK Company No: 5218868 Registered in England and Wales 
------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to