title: com.itextpdf.text.exceptions.InvalidPdfException: PDF header signature not found
body: <p>I am getting this error while trying to digitally sign the PDF document.
  passing the two pdfs SOURCEPDF name and DESTINATIONPDF name(digitally SIGNED) pdf name.
  after first digital signing on SOURCEPDF i get DESTINATIONPDF .
  for second digital signing am using DESTINATIONPDF as a source pdf as well as destination pdf.</p>
  
  <p>Here is my code</p>
  
  <pre><code>try
  {
      for(int i=1;i&lt;=signature_Count;i++)
      {
          if(i==1)
          {
              tmpPdfSource=sourcePdfPath;
          }else{
              this.tmpPdfSource=destinationPdfPath;
          }
  
          int pageNo=Integer.parseInt(ad.readXML(xmlString, rootName,"PageNo-"+i));
          String imageSource=ad.readXML(xmlString, rootName,"ImageSource-"+i);
          float llx=Float.parseFloat(ad.readXML(xmlString, rootName,"llx-"+i));
          float lly=Float.parseFloat(ad.readXML(xmlString, rootName,"lly-"+i));
          float urx=Float.parseFloat(ad.readXML(xmlString, rootName,"urx-"+i));
          float ury=Float.parseFloat(ad.readXML(xmlString, rootName,"ury-"+i));
          String signature=ad.readXML(xmlString, rootName,"SignatureName-"+i);
  
          File dest = new File(destinationPdfPath);
          KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
          ks.load(new Fil eInputStream(certificatePath), keystore_password.toCharArray());
          String alias = (String) ks.aliases().nextElement();
          PrivateKey pk = (PrivateKey) ks.getKey(alias,key_password.toCharArray());
          java.security.cert.Certificate[] chain = ks.getCertificateChain(alias);
          PdfReader reader = new PdfReader(tmpPdfSource);
          stamper = PdfStamper.createSignature(reader,new FileOutputStream(dest), '\0', null, true);
          PdfSignatureAppearance appearance = stamper.getSignatureAppearance();
  
          appearance.setCrypto(pk, chain, null,PdfSignatureAppearance.SELF_SIGNED);
  
          if (true)
          {
              appearance.setAcro6Layers(true);
              Image img=Image.getInstance(imageSource);
              appearance.setImage(img);
              appearance.setVisibleSignature(new com.itextpdf.text.Rectangle(llx, lly, urx, ury), pageNo, signature);
          }
      }//for
      stamper.close();
  } catch (Exception e) {
      GenericLog gl=new  GenericLog();
      gl.writeWarning("Error Occured in SignPdfDocument ");
      gl.writeError(e);
      e.printStackTrace();
  }
  </code></pre>
  
  <p>please Help me to FIX this error.</p>