Thanks -------- Original-Nachricht -------- Datum: Fri, 23 Feb 2007 15:15:50 -0000 Von: "Paulo Soares" <[EMAIL PROTECTED]> An: "Post all your questions about iText here" <[email protected]> CC: Betreff: Re: [iText-questions] sign a PDF
> Select the windows handler and it will work. You can also sign with the > PdfSignatureAppearance.WINCER_SIGNED and it will work directly. > > Paulo > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On > > Behalf Of Jens Kelkel > > Sent: Friday, February 23, 2007 10:14 AM > > To: Post all your questions about iText here > > Subject: Re: [iText-questions] sign a PDF > > > > Hallo, > > > > Thanks for the answer. I have found the solution. The > > keystore wasn't properly build. > > But next problem is that I get a message form Acrobat Reader > > (Version 8 German) that he couldn't find the handler to > > verify the Signature. > > > > Now anybody, how I add a handler to the document? > > > > Here my code that I use: > > > > > > KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); > > URL url= > > this.getClass().getClassLoader().getResource("anotherstore.jks"); > > ks.load(new FileInputStream(url.getPath()), > > "jk(JK)%jk".toCharArray()); > > String alias = (String)ks.aliases().nextElement(); > > PrivateKey key = (PrivateKey)ks.getKey(alias, > > "jk(JK)%jk".toCharArray()); > > > > Certificate[] chain = ks.getCertificateChain(alias); > > PdfReader reader2 = new PdfReader(out.toByteArray()); > > ByteArrayOutputStream fout = new ByteArrayOutputStream(); > > PdfStamper stp = PdfStamper.createSignature(reader2, fout, '\0'); > > PdfSignatureAppearance sap = stp.getSignatureAppearance(); > > sap.setCrypto(key, chain, null, > > PdfSignatureAppearance.VERISIGN_SIGNED); > > sap.setReason("Unterschrift Angebot"); > > sap.setLocation("Saarbrücken"); > > // comment next line to have an invisible signature > > sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null); > > sap.setCertified(true); > > stp.close(); > > > > Thanks > > > > Jens Kelkel > > > > -------- Original-Nachricht -------- > > Datum: Thu, 22 Feb 2007 15:32:06 -0000 > > Von: "Paulo Soares" <[EMAIL PROTECTED]> > > An: "Post all your questions about iText here" > > <[email protected]> > > CC: > > Betreff: Re: [iText-questions] sign a PDF > > > > > 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/ > > > > -- > > "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ... > > Jetzt GMX ProMail testen: www.gmx.net/de/go/mailfooter/promail-out > > > > -------------------------------------------------------------- > > ----------- > > 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/ -- "Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ... Jetzt GMX TopMail testen: www.gmx.net/de/go/mailfooter/topmail-out ------------------------------------------------------------------------- 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/
