本文整理匯總了C#中iTextSharp.text.pdf.PdfEncryption.SetupAllKeys方法的典型用法代碼示例。如果您正苦於以下問題:C# PdfEncryption.SetupAllKeys方法的具體用法?C# PdfEncryption.SetupAllKeys怎麽用?C# PdfEncryption.SetupAllKeys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類iTextSharp.text.pdf.PdfEncryption
的用法示例。
在下文中一共展示了PdfEncryption.SetupAllKeys方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SetEncryption
/** Sets the encryption options for this document. The userPassword and the
* ownerPassword can be null or have zero length. In this case the ownerPassword
* is replaced by a random string. 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.
* @param userPassword the user password. Can be null or empty
* @param ownerPassword the owner password. Can be null or empty
* @param permissions the user permissions
* @param encryptionType the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
* Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
* @throws DocumentException if the document is already open
*/
public void SetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType) {
if (pdf.IsOpen())
throw new DocumentException(MessageLocalization.GetComposedMessage("encryption.can.only.be.added.before.opening.the.document"));
crypto = new PdfEncryption();
crypto.SetCryptoMode(encryptionType, 0);
crypto.SetupAllKeys(userPassword, ownerPassword, permissions);
}
示例2: SetEncryption
/** Sets the encryption options for this document. The userPassword and the
* ownerPassword can be null or have zero length. In this case the ownerPassword
* is replaced by a random string. 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.
* @param userPassword the user password. Can be null or empty
* @param ownerPassword the owner password. Can be null or empty
* @param permissions the user permissions
* @param encryptionType the type of encryption. It can be one of STANDARD_ENCRYPTION_40, STANDARD_ENCRYPTION_128 or ENCRYPTION_AES128.
* Optionally DO_NOT_ENCRYPT_METADATA can be ored to output the metadata in cleartext
* @throws DocumentException if the document is already open
*/
public void SetEncryption(byte[] userPassword, byte[] ownerPassword, int permissions, int encryptionType)
{
if (pdf.IsOpen())
throw new DocumentException("Encryption can only be added before opening the document.");
crypto = new PdfEncryption();
crypto.SetCryptoMode(encryptionType, 0);
crypto.SetupAllKeys(userPassword, ownerPassword, permissions);
}