François Christophe wrote:
Thanks for the solution,
Here is what I did and it's working;
OK, that's good news,
I post your code snippet to the mailing list for future reference.
br,
Bruno
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("c:\\certificate\\certificate.pfx"),
"orionbs".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "orionbs".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
File file = new File("c:\\pdf\\original.pdf");
InputStream is = new FileInputStream(file);
long length = file.length();
byte[] bytes = new byte[(int)length];
int offset = 0;
int numRead = 0;
while (offset < bytes.length
&& (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
offset += numRead;
}
is.close();
PdfReader reader = new PdfReader(bytes);
FileOutputStream fout = new FileOutputStream("c:\\pdf\\original.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("Verified");
sap.setLocation("Bruxelles");
stp.close();
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid0944&bid$1720&dat1642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions