Hello,
I've made a simple jar to protect and sign PDFs where the signing part is
copied from this example:
http://itextpdf.sourceforge.net/howtosign.html#howtosign.
It works great from the command-line (Debian), but fails on the line
"ks.load(new FileInputStream("/path/to/cert/certificate.p12"),
"password".toCharArray());" when I try to execute the Jar using the PHP exec
function (exec("java -jar /path/to/jar/SignPDF.jar /path/to/pdf/original.pdf
/path/to/pdf/signed.pdf", $response);), although it doesn't return any error
message.
I've tried to chown to www-data and chmod to 777 the Jar and the certificate
files, but it didn't help.
Any suggestions about what might be wrong?
Please bear in mind that I'm quite unexperienced with both Java and iText.
Thank you,
Pedro
--------------------------
PdfReader reader = new PdfReader(src);
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("/path/to/cert/certificate.p12"),
"password".toCharArray());
String alias = ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
FileOutputStream fout = new FileOutputStream(dest);
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setVisibleSignature(new Rectangle(250, 130, 500, 190), 1, "Campo de firma");
sap.setCertificationLevel(PdfSignatureAppearance.CERTIFIED_NO_CHANGES_ALLOWED);
stp.close();------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model
configuration take the hassle out of deploying and managing Subversion and
the tools developers use with it. Learn more about uberSVN and get a free
download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
iText-questions mailing list
[email protected]
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