sap.setCrypto(key, chain, null, PdfSignatureAppearance.VERISIGN_SIGNED); Maybe key or chain are null.
Paulo > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Jens Kelkel > Sent: Thursday, February 22, 2007 2:16 PM > To: [email protected] > Subject: [iText-questions] sign a PDF > > Hello, > > I want to sign a PDF with the following code: > > KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); > System.out.println(ks.getProvider()); > ks.load(new > FileInputStream("C:\\j2sdk1.4.2_05\\bin\\keystore3.ks"), > pass.toCharArray()); > > String alias = (String)ks.aliases().nextElement(); > PrivateKey key = (PrivateKey)ks.getKey(alias, pass.toCharArray()); > > Certificate[] chain = ks.getCertificateChain(alias); > PdfReader reader = new PdfReader("c:\\Antrag.pdf"); > FileOutputStream fout = new FileOutputStream("c:\\signed.pdf"); > PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0'); > PdfSignatureAppearance sap = stp.getSignatureAppearance(); > sap.setCrypto(key, chain, null, > PdfSignatureAppearance.VERISIGN_SIGNED); > sap.setReason("I'm the author"); > sap.setLocation("Saarbrücken"); > sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null); > sap.setCertified(true); > stp.close(); > > If I use a self signed Certificate the code run with no > problem. But if I import my Versign Certificate in the > keystore I get the follow Message. > > java.lang.NullPointerException > at > com.lowagie.text.pdf.PdfSignatureAppearance.getAppearance(PdfS > ignatureAppearance.java:395) > at > com.lowagie.text.pdf.PdfSignatureAppearance.preClose(PdfSignat > ureAppearance.java:902) > at > com.lowagie.text.pdf.PdfSignatureAppearance.preClose(PdfSignat > ureAppearance.java:847) > at com.lowagie.text.pdf.PdfStamper.close(PdfStamper.java:175) > at de.jens.kelkel.PDFSignature.main(PDFSignature.java:89) > Exception in thread "main" > > Have anybody a solution fort hat problem?? > > -- > Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! > Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer > > -------------------------------------------------------------- > ----------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the > chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge > &CID=DEVDEV > _______________________________________________ > iText-questions mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/itext-questions > Buy the iText book: http://itext.ugent.be/itext-in-action/ > Aviso Legal: Esta mensagem é destinada exclusivamente ao destinatário. Pode conter informação confidencial ou legalmente protegida. A incorrecta transmissão desta mensagem não significa a perca de confidencialidade. Se esta mensagem for recebida por engano, por favor envie-a de volta para o remetente e apague-a do seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de usar, revelar ou distribuir qualquer parte desta mensagem. Disclaimer: This message is destined exclusively to the intended receiver. It may contain confidential or legally protected information. The incorrect transmission of this message does not mean the loss of its confidentiality. If this message is received by mistake, please send it back to the sender and delete it from your system immediately. It is forbidden to any person who is not the intended receiver to use, distribute or copy any part of this message. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys-and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
