Class PdfStandardSecurityHandler
Represents the standard PDF security handler.
public sealed class PdfStandardSecurityHandler : PdfSecurityHandler, ICloneable, IEnumerable<KeyValuePair<string, PdfItem?>>, IEnumerable
- Inheritance
-
PdfStandardSecurityHandler
- Implements
- Inherited Members
Properties
OwnerPassword
Sets the owner password of the document.
public string OwnerPassword { set; }
Property Value
UserPassword
Sets the user password of the document.
public string UserPassword { set; }
Property Value
Methods
AddCryptFilter(string, PdfCryptFilter, bool)
Adds a crypt filter to the document.
public void AddCryptFilter(string name, PdfCryptFilter cryptFilter, bool asDefault = false)
Parameters
name
stringThe name to identify the crypt filter.
cryptFilter
PdfCryptFilterThe crypt filter.
asDefault
boolIf true, the crypt filter is referred to as default for any strings and streams in StmF, StrF and EFF keys.
CreateCryptFilter()
Creates a crypt filter belonging to standard security handler.
public PdfCryptFilter CreateCryptFilter()
Returns
DecryptObject(PdfObject)
Decrypts an indirect PdfObject.
public void DecryptObject(PdfObject value)
Parameters
value
PdfObject
EncryptEmbeddedFileStreamsOnly()
Encrypts embedded file streams only by setting a crypt filter only in the security handler’s EFF key and setting the crypt filter’s AuthEvent Key to /EFOpen, in order authenticate embedded file streams when accessing the embedded file.
public void EncryptEmbeddedFileStreamsOnly()
GetCryptFilter(PdfDictionary)
Gets the crypt filter that shall be used to decrypt or encrypt the dictionary.
public CryptFilterBase? GetCryptFilter(PdfDictionary dictionary)
Parameters
dictionary
PdfDictionary
Returns
GetOrAddStandardCryptFilter(bool)
Returns the StdCF as it shall be used in encryption version 4 and 5. If not yet existing, it is created regarding the asDefaultIfNew parameter, which will set StdCF as default for streams, strings, and embedded file streams.
public PdfCryptFilter GetOrAddStandardCryptFilter(bool asDefaultIfNew = true)
Parameters
asDefaultIfNew
boolIf true and the crypt filter is newly created, the crypt filter is referred to as default for any strings, and streams in StmF, StrF and EFF keys.
Returns
RemoveCryptFilters()
Removes all crypt filters from the document.
public void RemoveCryptFilters()
ResetCryptFilter(PdfDictionary)
Resets the explicitly set crypt filter of a dictionary.
public void ResetCryptFilter(PdfDictionary dictionary)
Parameters
dictionary
PdfDictionary
SetCryptFilter(PdfDictionary, string)
Sets the dictionary’s explicitly set crypt filter to the desired crypt filter.
public void SetCryptFilter(PdfDictionary dictionary, string cryptFilterName)
Parameters
dictionary
PdfDictionarycryptFilterName
string
SetCryptFilterAsDefault(string?)
Sets the given crypt filter as default for streams, strings, and embedded streams. The crypt filter must be manually added crypt filter, "Identity" or null to remove the StmF, StrF and EFF key.
public void SetCryptFilterAsDefault(string? name)
Parameters
name
string
SetCryptFilterAsDefaultForEmbeddedFileStreams(string?)
Sets the given crypt filter as default for embedded file streams. The crypt filter must be manually added crypt filter, "Identity" or null to remove the EFF key.
public void SetCryptFilterAsDefaultForEmbeddedFileStreams(string? name)
Parameters
name
string
SetCryptFilterAsDefaultForStreams(string?)
Sets the given crypt filter as default for streams. The crypt filter must be manually added crypt filter, "Identity" or null to remove the StmF key.
public void SetCryptFilterAsDefaultForStreams(string? name)
Parameters
name
string
SetCryptFilterAsDefaultForStrings(string?)
Sets the given crypt filter as default for strings. The crypt filter must be manually added crypt filter, "Identity" or null to remove the StrF key.
public void SetCryptFilterAsDefaultForStrings(string? name)
Parameters
name
string
SetEncryption(PdfDefaultEncryption)
Set the encryption according to the given PdfDefaultEncryption. Allows setting the encryption automized using one single parameter.
public void SetEncryption(PdfDefaultEncryption encryption)
Parameters
encryption
PdfDefaultEncryption
SetEncryption(DefaultEncryption)
Set the encryption according to the given DefaultEncryption. Allows setting the encryption automized using one single parameter.
[Obsolete("Use SetEncryption(PdfDefaultEncryption encryption) instead.")]
public void SetEncryption(PdfStandardSecurityHandler.DefaultEncryption encryption)
Parameters
encryption
PdfStandardSecurityHandler.DefaultEncryption
SetEncryptionToNoneAndResetPasswords()
Do not encrypt the PDF file. Resets the user and owner password.
public void SetEncryptionToNoneAndResetPasswords()
SetEncryptionToV1()
Encrypt with Version 1 (RC4 and a file encryption key length of 40 bits).
public void SetEncryptionToV1()
SetEncryptionToV2(int)
Encrypt with Version 2 (RC4 and a file encryption key length of more than 40 bits, PDF 1.4).
public void SetEncryptionToV2(int length = 40)
Parameters
length
intThe file encryption key length - a multiple of 8 from 40 to 128 bit.
SetEncryptionToV2With128Bits()
Encrypt with Version 2 (RC4 and a file encryption key length of more than 40 bits, PDF 1.4) with a file encryption key length of 128 bits. This was the default encryption in PDFsharp 1.5.
public void SetEncryptionToV2With128Bits()
SetEncryptionToV4UsingAES(bool)
Encrypt with Version 4 (RC4 or AES and a file encryption key length of 128 bits using a crypt filter, PDF 1.5) using AES (PDF 1.6).
public void SetEncryptionToV4UsingAES(bool encryptMetadata = true)
Parameters
encryptMetadata
boolThe document metadata stream shall be encrypted (default: true).
SetEncryptionToV4UsingRC4(bool)
Encrypt with Version 4 (RC4 or AES and a file encryption key length of 128 bits using a crypt filter, PDF 1.5) using RC4.
public void SetEncryptionToV4UsingRC4(bool encryptMetadata = true)
Parameters
encryptMetadata
boolThe document metadata stream shall be encrypted (default: true).
SetEncryptionToV5(bool)
Encrypt with Version 5 (AES and a file encryption key length of 256 bits using a crypt filter, PDF 2.0).
public void SetEncryptionToV5(bool encryptMetadata = true)
Parameters
encryptMetadata
boolThe document metadata stream shall be encrypted (default: true).
SetIdentityCryptFilter(PdfDictionary)
Sets the dictionary’s explicitly set crypt filter to the Identity crypt filter.
public void SetIdentityCryptFilter(PdfDictionary dictionary)
Parameters
dictionary
PdfDictionary