Hi,

i am trying to sign PDF file using iText.

the code is working fine when i am using the Adobe Digital Signature and the
same code through an error when i am using the VeriSign digital signature.

please find the code below;

              File file = new File(l_file_path + mFileSeparator
                                    + "XXMON_INVOICE_PRINT_" + RequestId
                                    + "_1.PDF");
                if (!file.exists())
                  throw new FileNotFoundException("File "+ file.getPath() +
"doesn't exist");
              PdfReader reader = new PdfReader(file.getPath());
              KeyStore ks = KeyStore.getInstance("pkcs12");
              //KeyStore ks = KeyStore.getInstance("IBMJCE");
              ks.load(new
FileInputStream("/d11/oradata/MON_DATA/einvoice/ManuSharmaVeri.pfx"),"Technical77a".toCharArray());
              String alias = (String)ks.aliases().nextElement();
              PrivateKey key =
(PrivateKey)ks.getKey(alias,"Technical77a".toCharArray());
              Certificate[] chain = ks.getCertificateChain(alias);
              FileOutputStream fout = new
FileOutputStream("/d11/oradata/MON_DATA/einvoice/XXMON_INVOICE_PRINT_" +
RequestId + "_1.PDF");
              PdfStamper stp = PdfStamper.createSignature(reader, fout,
'\0');
              PdfSignatureAppearance sap = stp.getSignatureAppearance();
              sap.setCrypto(key, chain, null,
PdfSignatureAppearance.WINCER_SIGNED);
              //sap.setCrypto(key, chain, null,
PdfSignatureAppearance.SELF_SIGNED);
              sap.setReason("I'm the author");
              sap.setLocation("Delhi");
              //comment next line to have an invisible signature
              sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1,
null);
              stp.close();

error log;
java.lang.NullPointerException
        at com.lowagie.text.pdf.PdfSignatureAppearance.getAppearance(Unknown
Source)
        at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
        at com.lowagie.text.pdf.PdfSignatureAppearance.preClose(Unknown Source)
        at com.lowagie.text.pdf.PdfStamper.close(Unknown Source)
        at
oracle.apps.xxmon.PDFDigitalSignVeri.runProgram(PDFDigitalSignVeri.java:129)
        at oracle.apps.fnd.cp.request.Run.main(Run.java:161)

java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2)
Classic VM (build 1.4.2, J2RE 1.4.2 IBM AIX build ca142-20070708 (SR9) (JIT
enabled: jitc))

jar file used:
bcmail-jdk14-141.jar
bcprov-ext-jdk14-141.jar
bcprov-jdk14-141.jar
iText-2.1.4.jar

please suggest...

Thanks & Regards,
Manu
-- 
View this message in context: 
http://www.nabble.com/PDF-Digital-Signing-error-out-tp21432546p21432546.html
Sent from the iText - General mailing list archive at Nabble.com.


------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
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