code: public static PdfStamper createSignature(PdfReader reader, OutputStream os, char pdfVersion, File tempFile) throws DocumentException, IOException 
      {
          return createSignature(reader, os, pdfVersion, tempFile, false);
      }
docs: Applies a digital signature to a document. The returned PdfStamper
  can be used normally as the signature is only applied when closing.
  <p>
  A possible use is:
  <p>
  <pre>
  KeyStore ks = KeyStore.getInstance("pkcs12");
  ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
  String alias = (String)ks.aliases().nextElement();
  PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
  Certificate[] chain = ks.getCertificateChain(alias);
  PdfReader reader = new PdfReader("original.pdf");
  FileOutputStream fout = new FileOutputStream("signed.pdf");
  PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0', new File("/temp"));
  PdfSignatureAppearance sap = stp.getSignatureAppearance();
  sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
  sap.setReason("I'm the author");
  sap.setLocation("Lisbon");
  // comment next line to have an invisible signature
  sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
  stp.close();
  </pre>
  @param reader the original document
  @param os the output stream or <CODE>null</CODE> to keep the document in the temporary file
  @param pdfVersion the new pdf version or '\0' to keep the same version as the original
  document
  @param tempFile location of the temporary file. If it's a directory a temporary file will be created there.
  If it's a file it will be used directly. The file will be deleted on exit unless <CODE>os</CODE> is null.
  In that case the document can be retrieved directly from the temporary file. If it's <CODE>null</CODE>
  no temporary file will be created and memory will be used
  @return a <CODE>PdfStamper</CODE>
  @throws DocumentException on error
  @throws IOException on error