Signatures require knowledge and if you don't understand what you are doing you won't get far. Post a snippet of your code and I'll see if I can correct it.
> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Shivakumar B > Sent: Wednesday, October 26, 2005 12:04 PM > To: Paulo Soares > Cc: [email protected] > Subject: RE: [iText-questions] Reg: Pdf Signature Clarifications > > > Hi Paulo, > thankx for the tip, i've corrected the error & gave > the exclusion range as the length of the original pdf file. > Is that correct? > While putting the signature into the pdf, i gave the > following command. > > dic2.put(PdfName.CONTENTS, new > PdfString(out).setHexWriting(false)); > > when i open in Adobe, i get the following error, > > Error during signature verification. > > Signature contains incorrect, unrecognized, > corrupted or suspicious data. > Support Information: SigDict /Contents illegal data > > Is this something wrong with the code or should I use > trusted certificates to sign the pdf and then verify? > > > regards > Sivakumar.B > > > > > [EMAIL PROTECTED] > > 10/26/2005 06:17 PM To > Shivakumar B/SP/DBAsia/[EMAIL PROTECTED], > [email protected] > cc > Subject > RE: [iText-questions] Reg: Pdf Signature Clarifications > > > > > > > Several errors: > > - you can only sign a field at a time. The second field must be signed > in append mode. > > - the content "out" must have the size of the (exclusion - 2) / 2 > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On > > Behalf Of Shivakumar B > > Sent: Wednesday, October 26, 2005 8:13 AM > > To: [email protected] > > Subject: [iText-questions] Reg: Pdf Signature Clarifications > > > > > > Hi, > > I am trying to create a Blank Signature Field for an > > existing pdf, later, I will fill it up with the actual > > signature. The following are the steps done, > > > > 1. Used PdfStamper to read the existing pdf. > > 2. Used PdfFormField to create the Blank Signature > > Field. (Set the flags, added the annotation to the > > PdfStamper, closed the PdfStamper) > > 3. Signatures were generated outside. > > 4. Putting back the signatures to the pdf. This step > > is not quite clear to me. > > These steps were followed as given in the > > "howtosign.html" page with little modification. > > > > a) I read the pdf using the PdfReader, > > created the PdfStamper using the createSignature() method. > > b) Get the List of Acro Fields from the > > PdfStamper and get the Blank Signature Field Names. > > c) Created PdfSignatureAppearance from the > > PdfStamper. > > d) Created the PdfDictionary with the fields > > given in the sample > > (Is there any page which documents > > the constants and what we have to use for which purpose...) > > (How are we > > allocating the space for the contents?) > > e) Created a HashMap and called the > > preClose()..The Code throws NullPointer Exception here. > > f) Created another dictionary object, to > > which the signatures were added. > > (How do we calculate > > the byte space for the contents?) > > > > > > for your reference, the actual code is below, > > > > PdfStamper stp = > > PdfStamper.createSignature(reader, fout, '\0'); > > AcroFields af = stp.getAcroFields(); > > HashMap af_fields = af.getFields(); > > Iterator iter = af_fields.keySet().iterator(); > > Object key1 = null; > > while (iter.hasNext()) { > > key1 = iter.next(); > > log("Acro Fields Key : "+key1+" Value > > : "+af_fields.get(key1)); > > } > > ArrayList names = af.getBlankSignatureNames(); > > > > for (int k = 0; k < names.size(); ++k) { > > String name = (String)names.get(k); > > log("Signature name: " + name); > > PdfSignatureAppearance sap = > > stp.getSignatureAppearance(); > > log("creating the visible signature > > with name..."); > > sap.setVisibleSignature(new > > Rectangle(100,100,200,200), 1, name); > > log("creating the pdf dictionary to > > set the flags..."); > > PdfDictionary dic = new PdfDictionary(); > > dic.put(PdfName.FT, PdfName.SIG); > > dic.put(PdfName.FILTER, new > > PdfName("SAFE.PPKSF")); > > dic.put(PdfName.SUBFILTER, new > > PdfName("adbe.pkcs7.detached")); > > dic.put(PdfName.NAME, new > > PdfString(PdfPKCS7.getSubjectFields((X509Certificate) > > chain[0]).getField("CN"))); > > log("setting the dictionary to the > > appearance..."); > > sap.setCryptoDictionary(dic); > > HashMap exc = new HashMap(); > > exc.put(PdfName.CONTENTS, new > > Integer(0x2502)); > > log("preclosing the appearance"); > > sap.preClose(exc); > > PdfDictionary dic2 = new PdfDictionary(); > > byte[] out = readFile("signature_pdf.p7s"); > > dic2.put(PdfName.CONTENTS, new > > PdfString(out).setHexWriting(true)); > > sap.close(dic2); > > } > > stp.close(); > > > > any suggestion or help.. > > > > > > regards > > Sivakumar.B > > > > > > > > ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information _______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions
