[iText-questions] Multiple signatures problem
Hello, i'm trying to place multiple signatures on a PDF file (i need 4 signatures). I tried modifying OpenSignPDF but when i add more than two signatures i always get that only the first and the last one are valid while all the signatures among the two show a red X on them. For instance... lets say that i have 3 signatures, then the first and third signature are valid, but not the second. Same thing if i have 4 signatures: the first and fourth signature are valid but not the second and the third. This is a piece of the code that i am using: if (.) { //First signature pdfStamper = PdfStamper.createSignature(pdfReader, bos, '\0'); } else { //Other signatures pdfStamper = PdfStamper.createSignature(pdfReader, bos, '\0', null, true); } [CUT] if (.) { //First signature signApp.setReason(Author); signApp.setCertificationLevel( PdfSignatureAppearance.CERTIFIED_FORM_FILLING); signApp.setVisibleSignature(new Rectangle(100, 600, 200, 640), 1, null); PdfFormField sign2 = PdfFormField.createSignature( pdfStamper.getWriter()); sign2.setWidget(new Rectangle(200, 600, 300, 640), null); sign2.setFlags(PdfAnnotation.FLAGS_PRINT); sign2.setFieldName(sign2); sign2.setPage(1); pdfStamper.addAnnotation(sign2, 1); PdfFormField sign3 = PdfFormField.createSignature( pdfStamper.getWriter()); sign3.setWidget(new Rectangle(300, 600, 400, 640), null); sign3.setFlags(PdfAnnotation.FLAGS_PRINT); sign3.setFieldName(sign3); sign3.setPage(1); pdfStamper.addAnnotation(sign3, 1); PdfFormField sign4 = PdfFormField.createSignature( pdfStamper.getWriter()); sign4.setWidget(new Rectangle(400, 600, 500, 640), null); sign4.setFlags(PdfAnnotation.FLAGS_PRINT); sign4.setFieldName(sign4); sign4.setPage(1); pdfStamper.addAnnotation(sign4, 1); } else { //Other signatures signApp.setReason(Countersign); signApp.setCertificationLevel( PdfSignatureAppearance.NOT_CERTIFIED); signApp.setVisibleSignature(sign + (round+1)); //round tells me which field to sign } [CUT] Am i doing something wrong? Thank you, Luca - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
Re: [iText-questions] Multiple signatures problem
Ok, everything works now. It looks like a problem of OpenSignPDF... this is what they do: [CUT] PdfDictionary signDict = new PdfDictionary(); signDict.put(PdfName.FT, PdfName.SIG); signDict.put(PdfName.FILTER, new PdfName(Adobe.PPKLite)); signDict.put(PdfName.SUBFILTER, new PdfName(adbe.pkcs7.detached)); signDict.put(PdfName.M, new PdfDate(cal)); signDict.put(PdfName.NAME, new PdfString(PdfPKCS7.getSubjectFields((X509Certificate) certChain[0]).getField(CN))); PdfDictionary transParamsDict = new PdfDictionary(); transParamsDict.put(PdfName.P, new PdfNumber(1)); transParamsDict.put(PdfName.V, new PdfName(1.2)); transParamsDict.put(PdfName.TYPE, new PdfName(TransformParams)); PdfDictionary refDict = new PdfDictionary(); refDict.put(new PdfName(TransformMethod), new PdfName(DocMDP)); refDict.put(PdfName.TYPE, new PdfName(SigRef)); refDict.put(new PdfName(TransformParams), transParamsDict); PdfArray typesArray = new PdfArray(); typesArray.add(refDict); signDict.put(new PdfName(Reference), typesArray); signApp.setCryptoDictionary(signDict); [CUT] I have changed it into: PdfDictionary signDict = new PdfDictionary(); signDict.put(PdfName.FT, PdfName.SIG); signDict.put(PdfName.FILTER, new PdfName(Adobe.PPKLite)); signDict.put(PdfName.SUBFILTER, new PdfName(adbe.pkcs7.detached)); signDict.put(PdfName.M, new PdfDate(cal)); signDict.put(PdfName.NAME, new PdfString(PdfPKCS7.getSubjectFields((X509Certificate) certChain[0]).getField(CN))); signApp.setCryptoDictionary(signDict); and now it works fine. It looks like they were adding unecessary fields (maybe because they are using an old version of iText). Thank you, Luca On Dec 9, 2007 10:42 PM, Luca Tomat [EMAIL PROTECTED] wrote: Hello, i'm trying to place multiple signatures on a PDF file (i need 4 signatures). I tried modifying OpenSignPDF but when i add more than two signatures i always get that only the first and the last one are valid while all the signatures among the two show a red X on them. For instance... lets say that i have 3 signatures, then the first and third signature are valid, but not the second. Same thing if i have 4 signatures: the first and fourth signature are valid but not the second and the third. - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/
[iText-questions] Adding an empty signature-field and signing
Hello, I need to add two signature-fields and add a signature inside the first one. This is how i do it: .. .. //Lets create the two fields PdfFormField sign1 = PdfFormField.createSignature( pdfStamper.getWriter()); sign1.setWidget(new Rectangle(100, 600, 180, 640), null); sign1.setFlags(PdfAnnotation.FLAGS_PRINT); sign1.setFieldName(sign1); sign1.setPage(1); pdfStamper.addAnnotation(sign1, 1); PdfFormField sign2 = PdfFormField.createSignature( pdfStamper.getWriter()); sign2.setWidget(new Rectangle(200, 600, 280, 640), null); sign2.setFlags(PdfAnnotation.FLAGS_PRINT); sign2.setFieldName(sign2); sign2.setPage(1); pdfStamper.addAnnotation(sign2, 1); .. .. //Creating the signature for the first field PdfSignatureAppearanceOSP signApp; signApp = pdfStamper.getSignatureAppearance(); signApp.setCrypto(null, certChain, null, PdfSignatureAppearance.WINCER_SIGNED); signApp.setReason(Author); signApp.setCertified(2); signApp.setVisibleSignature(sign1); .. .. Unfortunately on the last line (signApp.setVisibleSignature(sign1);) i get the error: The field sign1 does not exist. Why? What am i doing wrong? Thank you, Luca - SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4___ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Buy the iText book: http://itext.ugent.be/itext-in-action/