Table of Contents

Class PdfDictionary.DictionaryElements

Namespace
PdfSharp.Pdf
Assembly
PdfSharp.dll

Represents the interface to the elements of a PDF dictionary.

public sealed class PdfDictionary.DictionaryElements : ElementsBase
Inheritance
object
PdfDictionary.DictionaryElements
Inherited Members

Properties

ArrayOrSingleItem

Access a key that may contain an array or a single item for working with its value(s).

Count

Gets the number of elements contained in the dictionary.

IsFixedSize

Return false.

IsReadOnly

Gets a value indicating whether the System.Collections.IDictionary object is read-only.

IsSynchronized

Return false.

this[Name]

Gets or sets an entry in the dictionary identified by a Name.

this[PdfName]

Gets or sets an entry in the dictionary identified by a PdfName object.

this[string]

Gets or sets an entry in the dictionary. The specified key must be a valid PDF name starting with a slash '/'. This property provides full access to the elements of the PDF dictionary. Wrong use can lead to errors or corrupt PDF files. TODO: review: New in 6.3: Gets or sets an entry in the dictionary. The getter returns null if no value with the specified key exists. If the value is a PdfReference this value is returned, i.e. in contrast to GetValue it is not dereferenced to its indirect object. The setter throws an ArgumentNullException if the value is null. If you try to set an indirect object its PdfReference is set instead. It is not possible to have a .NET reference to an indirect PdfObject.

KeyNames

Gets all keys currently in use in this dictionary as an array of PdfName objects.

Keys

Get all keys currently in use in this dictionary as an array of string objects.

OwningDictionary

The dictionary this elements object belongs to.

SyncRoot

The current implementation returns null.

Values

Gets all values currently in use in this dictionary as an array of PdfItem objects.

Methods

Add(KeyValuePair<string, PdfItem>)

Adds an item to the dictionary.

Add(string, PdfItem)

Adds the specified value to the dictionary. If the value is an indirect object, the PdfReference is added instead. If the value is a direct object that war previously added to another dictionary or array, an exception is thrown.

Clear()

Removes all elements from the dictionary.

Clone()

Creates a shallow copy of this object. The clone is not owned by a dictionary anymore.

Contains(KeyValuePair<string, PdfItem>)

Determines whether the dictionary contains a specific key.

ContainsKey(string)

Determines whether the dictionary contains the specified name.

CopyTo(KeyValuePair<string, PdfItem>[], int)

Copies the elements of the dictionary to an array, starting at a particular index.

GetArray(string, VCF, Type?)

Gets the PdfArray with the specified key, or null, if no such object exists and should not be created. If the key refers to a reference, the referenced PdfArray is returned. If the array exists, but cannot be transformed to type T, an exception is thrown.

GetArray<T>(string, VCF)

Gets the PdfArray with the specified key, or null, if no such object exists and should not be created. If the key refers to a reference, the referenced PdfArray is returned. If the array exists, but cannot be transformed to type T, an exception is thrown.

GetBoolean(string, bool, bool)

Gets the boolean value that corresponds to the specified key. If the key does not exist and create is false, the function returns the defaultValue. If the key does not exist and create is true, a direct value will be created using the defaultValue. If the key exists but the value is neither a boolean nor a PDF reference to a boolean, the function throws an InvalidOperationException.

GetDateTime(string, DateTimeOffset?, bool)

Converts the specified value to DateTimeOffset. If the value does not exist, the function returns the specified default value. If the value is not convertible, the function throws an InvalidOperationException.

GetDictionary(string, VCF, Type?)

Gets the PdfDictionary with the specified key, or null, if no such object exists and should not be created. If the key refers to a reference, the referenced PdfDictionary is returned.

GetDictionary<T>(string, VCF)

Gets the PdfDictionary with the specified key, or null, if no such object exists and should not be created. If the key refers to a reference, the referenced PdfDictionary is returned. If the dictionary exists, but cannot be transformed to type T, an exception is thrown.

GetEnumFromName(string, object, bool)
GetEnum<TEnum>(string)
GetEnumerator()

Returns an System.Collections.IDictionaryEnumerator object for the System.Collections.IDictionary object.

GetInteger(string, bool, int)

Gets the integer value that corresponds to the specified key. If the key does not exist and create is false, the function returns the defaultValue. If the key does not exist and create is true, a direct value will be created using the defaultValue. If the key exists but the value is neither an integer nor a PDF reference to an integer, the function throws an InvalidOperationException.

GetLongInteger(string, bool, long)

Gets the integer or long integer value that corresponds to the specified key. If the key does not exist and create is false, the function returns the defaultValue. If the key does not exist and create is true, a direct value will be created using the defaultValue. If the key exists but the value is neither an integer or a long integer nor a PDF reference to an integer or a long integer, the function throws an InvalidOperationException.

GetMatrix(string, bool, XMatrix?)
GetName(string, bool, string)

Gets the name value that corresponds to the specified key. If the key does not exist and create is false, the function returns the defaultValue. If the key does not exist and create is true, a direct value will be created using the defaultValue. If the key exists but the value is neither a name nor a PDF reference to a name, the function throws an InvalidOperationException. Note that the default defaultValue is the empty name ("/"), not the empty string.

GetObject(string, VCF, Type?)

Gets the PdfObject with the specified key, or null if no such object exists. If the key refers to a reference, the referenced PdfObject is returned. *

GetObject<T>(string, VCF)
GetReal(string, bool, double)

Gets the real or integer value that corresponds to the specified key. If the key does not exist and create is false, the function returns the defaultValue. If the key does not exist and create is true, a direct value will be created using the defaultValue. If the key exists but the value is neither a real or an integer nor a PDF reference to a real or an integer, the function throws an InvalidOperationException.

GetRectangle(string, bool, PdfRectangle?)

Gets the rectangle value that corresponds to the specified key. If the key does not exist and create is false, the function returns the defaultValue. If the key does not exist and create is true, a direct value will be created using the defaultValue. If the key exists but the value is neither a rectangle or an array with four elements nor a PDF reference to a rectangle or an array with four elements, the function throws an InvalidOperationException.

GetReference(string)

Gets the PdfReference with the specified key, or null if no such object exists.

GetRequiredArray(string, VCF, Type?)
GetRequiredArray<T>(string, VCF)

Gets the PdfArray with the specified key, or throws an exception, if no such object exists and should not be created. If the key refers to a reference, the referenced PdfArray is returned. If the array exists, but cannot be transformed to type T, an exception is thrown.

GetRequiredDateTime(string, DateTimeOffset?, bool)
GetRequiredDictionary(string, VCF, Type?)
GetRequiredDictionary<T>(string, VCF)

Gets the PdfDictionary with the specified key, or throws an exception, if no such object exists and should not be created. If the key refers to a reference, the referenced PdfDictionary is returned. If the dictionary exists, but cannot be transformed to type T, an exception is thrown.

GetRequiredObject(string, VCF, Type?)
GetRequiredObject<T>(string, VCF)
GetRequiredRectangle(string, bool, PdfRectangle?)
GetRequiredReference(string)

Gets the PdfReference with the specified key, or throws an exception, if no such object exists.

GetRequiredValue(string, VCF, Type?)

Gets the result as GetValue if it is not null. Otherwise, an exception is thrown.

GetRequiredValue<T>(string, VCF)
GetString(string, bool, string)

Gets the string value that corresponds to the specified key. If the key does not exist and create is false, the function returns the defaultValue. If the key does not exist and create is true, a direct value will be created using the defaultValue. If the key exists but the value is neither a string or name nor a PDF reference to a string or a name, the function throws an InvalidOperationException.

GetUnsignedInteger(string, bool, uint)

Gets the unsigned integer value that corresponds to the specified key. If the key does not exist and create is false, the function returns the defaultValue. If the key does not exist and create is true, a direct value will be created using the defaultValue. If the key exists but the value is neither an integer nor a PDF reference to an integer, the function throws an InvalidOperationException.

GetValue(string, VCF, Type?)

Gets the value for the specified key. If the value does not exist, it is optionally created. If the value is a PDF reference the referenced object is returned, except the itemType is set to PdfReference.

GetValue<T>(string, VCF)
HasValue(string)

Determines whether the specified key has a value.

Remove(KeyValuePair<string, PdfItem>)

Removes the value with the specified key.

Remove(string)

Removes the value with the specified key.

SetBoolean(string, bool)

Sets the entry to a direct boolean value.

SetDateTime(string, DateTime)

Sets the entry to a direct datetime value.

SetDateTime(string, DateTimeOffset)

Sets the entry to a direct datetime value.

SetEnumAsName(string, object)
SetInteger(string, int)

Sets the entry to a direct integer value.

SetIntegerFlag(string, int)

Sets the entry to a direct integer value that is used as a flag.

SetLongInteger(string, long)

Sets the entry to a direct long integer value.

SetMatrix(string, XMatrix)

Sets the entry to a direct matrix value, represented by an array with six values.

SetName(string, string)

Sets a PDF name at the specified key. If the value doesn’t start with a slash, it is added automatically, but starting with PDFsharp version 6.3 a warning is logged.

SetName<T>(string, T)
SetObject(string, PdfObject)

Sets the entry to the specified object.

SetReal(string, double)

Sets the entry to a direct double value.

SetRectangle(string, PdfRectangle)

Sets the entry to a direct rectangle value, represented by an array with four values.

SetReference(string, PdfReference)

Sets the entry to an indirect reference.

SetReference(string, PdfObject)

Sets the entry to an indirect reference. The specified object must be an indirect object, otherwise an exception is raised.

SetString(string, string)

Sets the entry to a direct string value.

SetValue(string, PdfItem)

Sets the entry with the specified value. DON’T USE THIS FUNCTION - IT MAY BE REMOVED. // PDFsharp/NT

TryGetArray(string, out PdfArray)
TryGetArray(string, out PdfArray, Type?)
TryGetArray<T>(string, out T)
TryGetBoolean(string, out bool)

Tries to get the boolean value of the PDF object with the specified key. Returns true on success, false otherwise.

TryGetDateTime(string, out DateTimeOffset?)

Tries to get the date value for the specified key. Returns true on success, false if value is of wrong type.

TryGetDictionary(string, out PdfDictionary)
TryGetDictionary(string, out PdfDictionary, Type?)
TryGetDictionary<T>(string, out T)
TryGetEnum<TEnum>(string, out TEnum)
TryGetInteger(string, out int)

Tries to get the integer value for the specified key. Returns true on success, false if value is of wrong type.

TryGetLongInteger(string, out long)

Tries to get the long integer value for the specified key. Returns true on success, false if value is of wrong type.

TryGetName(string, out string)

Tries to get the name value for the specified key. Returns true on success, false if value is of wrong type.

TryGetReal(string, out double)

Tries to get the real value for the specified key. Returns true on success, false if value is of wrong type.

TryGetRectangle(string, out PdfRectangle)

Tries to get the rectangle value for the specified key. Returns true on success, false if value is of wrong type.

TryGetString(string, out string)

Tries to get the name value for the specified key. Returns true on success, false if value is of wrong type.

TryGetUnsignedInteger(string, out uint)

Tries to get the unsigned integer value for the specified key. Returns true on success, false if value is of wrong type.

TryGetValue(string, out PdfItem)

Gets the value associated with the specified key.

TryGetValue(string, out PdfItem, Type?)
TryGetValue<T>(string, out T)