iTextSharp.text.pdf.PdfEncryption.AddRecipient C# (CSharp) Метод

AddRecipient() публичный Метод

public AddRecipient ( X509Certificate cert, int permission ) : void
cert Org.BouncyCastle.X509.X509Certificate
permission int
Результат void
        public void AddRecipient(X509Certificate cert, int permission)
        {
            documentID = CreateDocumentId();
            publicKeyHandler.AddRecipient(new PdfPublicKeyRecipient(cert, permission));
        }

Usage Example

Пример #1
0
 /**
 * 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 certicates
 * @param encryptionType the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
 * @throws DocumentException if the document is already open
 */
 public void SetEncryption(X509Certificate[] certs, int[] permissions, int encryptionType) {
     if (pdf.IsOpen())
         throw new DocumentException(MessageLocalization.GetComposedMessage("encryption.can.only.be.added.before.opening.the.document"));
     crypto = new PdfEncryption();
     if (certs != null) {
         for (int i=0; i < certs.Length; i++) {
             crypto.AddRecipient(certs[i], permissions[i]);
         }
     }
     crypto.SetCryptoMode(encryptionType, 0);
     crypto.GetEncryptionDictionary();
 }
All Usage Examples Of iTextSharp.text.pdf.PdfEncryption::AddRecipient