Hi,

    I am having some problems using itext api in PDF for the digital
signature.

1)   I am using the below code to sign the PDF digitally. After adding the
signature it showing that the signature as "Validity Unknown".
     how to currect this one ?
2) And how to validate the signature, whether signature from currect person
or not?
3) i having a requirement in that 1st person will sign after that next
person will edit that pdf and he also sign that pdf. how to verify in this
case?

My code>>>>>>>>>>>>

  File outputFile= null;
  PdfStamper pdfStamper = null;
  PdfSignatureAppearance sap=null;
  try{
   PrivateKey key = null;
   Certificate[] chain = null;

   if (!keystore.exists())
    return false;

   if (reason != null)
   {
    KeyStore ks = KeyStore.getInstance(keystoreType);
    FileInputStream fis = new FileInputStream(keystore);
    try
    {
     ks.load(fis, keystorePassword);
     fis.close();
    }
    finally { fis.close(); }

    String alias = (String) ks.aliases().nextElement();
    key = (PrivateKey) ks.getKey(alias, privateKeyPassword);
    chain = ks.getCertificateChain(alias);
   }

   PdfReader pdfReader = new PdfReader(srcFileName);
   int n = pdfReader.getNumberOfPages();
   outputFile = new File(pdfOutfile);


    pdfStamper = PdfStamper.createSignature(pdfReader, null, '\0',
outputFile);
    sap = pdfStamper.getSignatureAppearance();
           sap.setCrypto(key, chain, null,
PdfSignatureAppearance.SELF_SIGNED);
    sap.setVisibleSignature(new Rectangle(700, 100, 350, 190), 1, null);
           sap.setReason(reason);
     sap.setLocation(location);
     sap.setCertified(false);
   if (userPassword != null)
    pdfStamper.setEncryption(true, userPassword, ownerPassword,
PdfWriter.AllowPrinting | PdfWriter.AllowCopy | PdfWriter.AllowScreenReaders|
PdfWriter.AllowDegradedPrinting);
    pdfStamper.setFormFlattening(true);
    HashMap moreInfo = new HashMap();
          moreInfo.put("Author", ""+userName);
          pdfStamper.setMoreInfo(moreInfo);

          int i = 0;
          PdfContentByte over;

          BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA,
BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);


          while (i < n) {
           i++;
           over = pdfStamper.getOverContent(i);
           over.beginText();
           over.setFontAndSize(bf, 18);
           over.setTextMatrix(30, 30);
           over.setFontAndSize(bf, 12);
           over.setFontAndSize(bf, 14);
           over.showTextAligned(Element.ALIGN_LEFT, ""+userName, 400, 130,
0);

           over.endText();
----------------------------
    Please clarify my doubts.And it is greate if you give the code for these
functionality i am new to this Digital signature...


Thanks & Regards,
Prashanth
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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/

Reply via email to