PDFsharp-net6

PdfCryptFilter

Namespace: PdfSharp.Pdf.Security

Represents a crypt filter dictionary as written into the CF dictionary of a security handler (PDFCryptFilters).

public class PdfCryptFilter : CryptFilterBase, System.ICloneable, System.Collections.Generic.IEnumerable`1[[System.Collections.Generic.KeyValuePair`2[[System.String, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[PdfSharp.Pdf.PdfItem, PdfSharp, Version=0.1.3.0, Culture=neutral, PublicKeyToken=null]], System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Collections.IEnumerable

Inheritance ObjectPdfItemPdfObjectPdfDictionaryCryptFilterBasePdfCryptFilter
Implements ICloneable, IEnumerable<KeyValuePair<String, PdfItem>>, IEnumerable

Properties

Elements

Gets the dictionary containing the elements of this dictionary.

public DictionaryElements Elements { get; }

Property Value

DictionaryElements

Stream

Gets or sets the PDF stream belonging to this dictionary. Returns null if the dictionary has no stream. To create the stream, call the CreateStream function.

public PdfStream Stream { get; set; }

Property Value

PdfStream

Owner

Gets the PdfDocument this object belongs to.

public PdfDocument Owner { get; }

Property Value

PdfDocument

IsIndirect

Indicates whether the object is an indirect object.

public bool IsIndirect { get; }

Property Value

Boolean

Internals

Gets the PdfInternals object of this document, that grants access to some internal structures which are not part of the public interface of PdfDocument.

public PdfObjectInternals Internals { get; }

Property Value

PdfObjectInternals

Reference

Gets the indirect reference of this object. If the value is null, this object is a direct object.

public PdfReference Reference { get; internal set; }

Property Value

PdfReference

ReferenceNotNull

Gets the indirect reference of this object. Throws if it is null.

public PdfReference ReferenceNotNull { get; }

Property Value

PdfReference

Exceptions

InvalidOperationException
The indirect reference must be not null here.

Constructors

PdfCryptFilter(PdfStandardSecurityHandler)

Initializes a new instance of the PdfCryptFilter class.

public PdfCryptFilter(PdfStandardSecurityHandler parentStandardSecurityHandler)

Parameters

parentStandardSecurityHandler PdfStandardSecurityHandler
The parent standard security handler.

Methods

Initialize(PdfStandardSecurityHandler)

Initializes _parentStandardSecurityHandler to do the correct interpretation of the length key.

public void Initialize(PdfStandardSecurityHandler parentStandardSecurityHandler)

Parameters

parentStandardSecurityHandler PdfStandardSecurityHandler

SetEncryptionToNone()

The encryption shall be handled by the security handler.

public void SetEncryptionToNone()

SetEncryptionToRC4ForV4(Int32)

Encrypt with RC4 and the given file encryption key length, using the algorithms of encryption V4 (PDF 1.5). For encryption V4 the file encryption key length shall be 128 bits.

public void SetEncryptionToRC4ForV4(int length)

Parameters

length Int32
The file encryption key length - a multiple of 8 from 40 to 256 bit.

SetEncryptionToAESForV4()

Encrypt with AES and a file encryption key length of 128 bits, using the algorithms of encryption V4 (PDF 1.6).

public void SetEncryptionToAESForV4()

SetEncryptionToAESForV5()

Encrypt with AES and a file encryption key length of 256 bits, using the algorithms of encryption V5 (PDF 2.0).

public void SetEncryptionToAESForV5()

SetAuthEventForEmbeddedFiles()

Sets the AuthEvent Key to /EFOpen, in order authenticate embedded file streams when accessing the embedded file.

public void SetAuthEventForEmbeddedFiles()

PrepareForProcessing()

Does all necessary initialization for reading and decrypting or encrypting and writing the document with this crypt filter.

internal void PrepareForProcessing()

EncryptForEnteredObject(Byte[]&)

Encrypts the given bytes.

internal bool EncryptForEnteredObject(Byte[]& bytes)

Parameters

bytes Byte[]&

Returns

Boolean
True, if the crypt filter encrypted the bytes, or false, if the security handler shall do it.

DecryptForEnteredObject(Byte[]&)

Decrypts the given bytes.

internal bool DecryptForEnteredObject(Byte[]& bytes)

Parameters

bytes Byte[]&

Returns

Boolean
True, if the crypt filter decrypted the bytes, or false, if the security handler shall do it.