code: public void setEncryption(Certificate[] certs, int[] permissions, int encryptionType) throws DocumentException {
          if (stamper.isAppend())
              throw new DocumentException("Append mode does not support changing the encryption status.");
          if (stamper.isContentWritten())
              throw new DocumentException("Content was already written to the output.");
          stamper.setEncryption(certs, permissions, encryptionType);
       }
docs: Sets the certificate encryption options for this document. An array of one or more public certificates
  must be provided together with an array of the same size for the permissions for each certificate.
  The open permissions for the document can be
  AllowPrinting, AllowModifyContents, AllowCopy, AllowModifyAnnotations,
  AllowFillIn, AllowScreenReaders, AllowAssembly and AllowDegradedPrinting.
  The permissions can be combined by ORing them.
  Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
  @param certs the public certificates to be used for the encryption
  @param permissions the user permissions for each of the certificates
  @param encryptionType the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
  @throws DocumentException if the encryption was set too late