I've found how to solve the problem....
PdfReader reader = new PdfReader(parsedSignature.getSignatureFileBytes());
            AcroFields af = reader.getAcroFields();
            ArrayList names = af.getSignatureNames();
            for (Object name1 : names) {
                String name = (String) name1;
                PdfDictionary dic = af.getSignatureDictionary(name);
                PdfObject obj = dic.get(PdfName.CONTENTS);
                PKCS7 p7 = new PKCS7(obj.getBytes());
                result = p7.getSignerInfos()[0].getEncryptedDigest();
            }


--- On Tue, 6/17/08, Dimiter Nikolov <[EMAIL PROTECTED]> wrote:

> From: Dimiter Nikolov <[EMAIL PROTECTED]>
> Subject: [iText-questions] Get PDF Signature bytes
> To: [email protected]
> Date: Tuesday, June 17, 2008, 4:59 PM
> I have signed PDF document. I have to get its signature
> bytes - not to verify the signature. How can I do that -
> I' ve tried the following :
> try{
>             PdfReader reader = new
> PdfReader(signedDocBytes);
>             AcroFields af = reader.getAcroFields();
>             ArrayList names = af.getSignatureNames();
>             for (Object name1 : names) {
>                 String name = (String) name1;
>                 PdfPKCS7 pk = af.verifySignature(name);
>                 byte[] ssig = pk.getEncodedPKCS7();
>                 System.out.println("TEST : " +
> ssig);
>             }
>         } catch (IOException e) {
>             Auxilary.logException(e);
>         }
> 
> but an exception have been thrown : SignatureException:
> object not initialized for signing. 
> 
> Thanks in advance :)
> Dimitar Nikolov
> 
> 
> 
>       
> 
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
> http://sourceforge.net/services/buy/index.php
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> 
> Do you like iText?
> Buy the iText book: http://www.1t3xt.com/docs/book.php
> Or leave a tip: https://tipit.to/itexttipjar


      

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Do you like iText?
Buy the iText book: http://www.1t3xt.com/docs/book.php
Or leave a tip: https://tipit.to/itexttipjar

Reply via email to