Thank you for your reply 1T3XT BVBA. Yes IText version is 5.1.2 
sorry for the mistake.

I used the libraries that you suggested and I got this exception:

Exception in thread "main" java.lang.NoSuchMethodError:
org.bouncycastle.asn1.DERSequence.<init>(Lorg/bouncycastle/asn1
/ASN1EncodableVector;)V

Any suggestions?

This is the java IText code that I am using for signing a created pdf:

String keystorePath = "certificate.pfx";
PdfReader reader = new PdfReader("c:\\prueba_itext.pdf");
ByteArrayOutputStream fout = new ByteArrayOutputStream();
//Cargar certificado de fichero PFX
KeyStore ks = KeyStore.getInstance("PKCS12","BC");
ks.load(new FileInputStream(new File(keystorePath)),
"password".toCharArray());
String alias = (String)ks.aliases().nextElement();
java.security.cert.Certificate[] chain = ks.getCertificateChain(alias);
PrivateKey pk = (PrivateKey)ks.getKey(alias, "".toCharArray());
PdfStamper stamper = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
appearance.setCrypto(
pk, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
stamper.close();
FileOutputStream fos = new FileOutputStream(new
File("c:\\prueba_itext_signed.pdf"));
fos.write(fout.toByteArray());
fos.flush();
fos.close();



------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions

iText(R) is a registered trademark of 1T3XT BVBA.
Many questions posted to this list can (and will) be answered with a reference 
to the iText book: http://www.itextpdf.com/book/
Please check the keywords list before you ask for examples: 
http://itextpdf.com/themes/keywords.php

Reply via email to