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 : IDictionary<string, PdfItem?>, ICollection<KeyValuePair<string, PdfItem?>>, IEnumerable<KeyValuePair<string, PdfItem?>>, IEnumerable, ICloneable
Inheritance
PdfDictionary.DictionaryElements
Implements
Inherited Members

Properties

ArrayOrSingleItem

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

public ArrayOrSingleItemHelper ArrayOrSingleItem { get; }

Property Value

ArrayOrSingleItemHelper

Count

Gets the number of elements contained in the dictionary.

public int Count { get; }

Property Value

int

IsFixedSize

Return false.

public bool IsFixedSize { get; }

Property Value

bool

IsReadOnly

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

public bool IsReadOnly { get; }

Property Value

bool

IsSynchronized

Return false.

public bool IsSynchronized { get; }

Property Value

bool

this[PdfName]

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

public PdfItem? this[PdfName key] { get; set; }

Parameters

key PdfName

Property Value

PdfItem

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.

public PdfItem? this[string key] { get; set; }

Parameters

key string

Property Value

PdfItem

KeyNames

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

public PdfName[] KeyNames { get; }

Property Value

PdfName[]

Keys

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

public ICollection<string> Keys { get; }

Property Value

ICollection<string>

SyncRoot

The current implementation returns null.

public object SyncRoot { get; }

Property Value

object

Values

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

public ICollection<PdfItem?> Values { get; }

Property Value

ICollection<PdfItem>

Methods

Add(KeyValuePair<string, PdfItem?>)

Adds an item to the dictionary.

public void Add(KeyValuePair<string, PdfItem?> item)

Parameters

item KeyValuePair<string, PdfItem>

Add(string, PdfItem?)

Adds the specified value to the dictionary.

public void Add(string key, PdfItem? value)

Parameters

key string
value PdfItem

Clear()

Removes all elements from the dictionary.

public void Clear()

Clone()

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

public PdfDictionary.DictionaryElements Clone()

Returns

PdfDictionary.DictionaryElements

Contains(KeyValuePair<string, PdfItem?>)

Determines whether the dictionary contains a specific value.

public bool Contains(KeyValuePair<string, PdfItem?> item)

Parameters

item KeyValuePair<string, PdfItem>

Returns

bool

ContainsKey(string)

Determines whether the dictionary contains the specified name.

public bool ContainsKey(string key)

Parameters

key string

Returns

bool

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

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

public void CopyTo(KeyValuePair<string, PdfItem?>[] array, int arrayIndex)

Parameters

array KeyValuePair<string, PdfItem>[]
arrayIndex int

GetArray(string)

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

public PdfArray? GetArray(string key)

Parameters

key string

Returns

PdfArray

GetBoolean(string)

Converts the specified value to boolean. If the value does not exist, the function returns false. If the value is not convertible, the function throws an InvalidCastException.

public bool GetBoolean(string key)

Parameters

key string

Returns

bool

GetBoolean(string, bool)

Converts the specified value to boolean. If the value does not exist, the function returns false. If the value is not convertible, the function throws an InvalidCastException.

public bool GetBoolean(string key, bool create)

Parameters

key string
create bool

Returns

bool

GetDateTime(string, DateTime)

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

public DateTime GetDateTime(string key, DateTime defaultValue)

Parameters

key string
defaultValue DateTime

Returns

DateTime

GetDictionary(string)

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

public PdfDictionary? GetDictionary(string key)

Parameters

key string

Returns

PdfDictionary

GetEnumerator()

Returns an IDictionaryEnumerator object for the IDictionary object.

public IEnumerator<KeyValuePair<string, PdfItem?>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<string, PdfItem>>

GetInteger(string)

Converts the specified value to integer. If the value does not exist, the function returns 0. If the value is not convertible, the function throws an InvalidCastException.

public int GetInteger(string key)

Parameters

key string

Returns

int

GetInteger(string, bool)

Converts the specified value to integer. If the value does not exist, the function returns 0. If the value is not convertible, the function throws an InvalidCastException.

public int GetInteger(string key, bool create)

Parameters

key string
create bool

Returns

int

GetMatrix(string)

public XMatrix GetMatrix(string key)

Parameters

key string

Returns

XMatrix

GetMatrix(string, bool)

public XMatrix GetMatrix(string key, bool create)

Parameters

key string
create bool

Returns

XMatrix

GetName(string)

Converts the specified value to a name. If the value does not exist, the function returns the empty string.

public string GetName(string key)

Parameters

key string

Returns

string

GetObject(string)

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.

public PdfObject? GetObject(string key)

Parameters

key string

Returns

PdfObject

GetReal(string)

Converts the specified value to double. If the value does not exist, the function returns 0. If the value is not convertible, the function throws an InvalidCastException.

public double GetReal(string key)

Parameters

key string

Returns

double

GetReal(string, bool)

Converts the specified value to double. If the value does not exist, the function returns 0. If the value is not convertible, the function throws an InvalidCastException.

public double GetReal(string key, bool create)

Parameters

key string
create bool

Returns

double

GetRectangle(string)

Converts the specified value to PdfRectangle. If the value does not exist, the function returns an empty rectangle. If the value is not convertible, the function throws an InvalidCastException.

public PdfRectangle GetRectangle(string key)

Parameters

key string

Returns

PdfRectangle

GetRectangle(string, bool)

Converts the specified value to PdfRectangle. If the value does not exist, the function returns an empty rectangle. If the value is not convertible, the function throws an InvalidCastException.

public PdfRectangle GetRectangle(string key, bool create)

Parameters

key string
create bool

Returns

PdfRectangle

GetReference(string)

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

public PdfReference? GetReference(string key)

Parameters

key string

Returns

PdfReference

GetString(string)

Converts the specified value to String. If the value does not exist, the function returns the empty string.

public string GetString(string key)

Parameters

key string

Returns

string

GetString(string, bool)

Converts the specified value to String. If the value does not exist, the function returns the empty string.

public string GetString(string key, bool create)

Parameters

key string
create bool

Returns

string

GetUnsignedInteger(string)

Converts the specified value to integer. If the value does not exist, the function returns 0. If the value is not convertible, the function throws an InvalidCastException.

public uint GetUnsignedInteger(string key)

Parameters

key string

Returns

uint

GetUnsignedInteger(string, bool)

Converts the specified value to unsigned integer. If the value does not exist, the function returns 0. If the value is not convertible, the function throws an InvalidCastException.

public uint GetUnsignedInteger(string key, bool create)

Parameters

key string
create bool

Returns

uint

GetValue(string)

Short cut for GetValue(key, VCF.None).

public PdfItem? GetValue(string key)

Parameters

key string

Returns

PdfItem

GetValue(string, VCF)

Gets the value for the specified key. If the value does not exist, it is optionally created.

public PdfItem? GetValue(string key, VCF options)

Parameters

key string
options VCF

Returns

PdfItem

Remove(KeyValuePair<string, PdfItem?>)

Removes the value with the specified key.

public bool Remove(KeyValuePair<string, PdfItem?> item)

Parameters

item KeyValuePair<string, PdfItem>

Returns

bool

Remove(string)

Removes the value with the specified key.

public bool Remove(string key)

Parameters

key string

Returns

bool

SetBoolean(string, bool)

Sets the entry to a direct boolean value.

public void SetBoolean(string key, bool value)

Parameters

key string
value bool

SetDateTime(string, DateTime)

Sets the entry to a direct datetime value.

public void SetDateTime(string key, DateTime value)

Parameters

key string
value DateTime

SetInteger(string, int)

Sets the entry to a direct integer value.

public void SetInteger(string key, int value)

Parameters

key string
value int

SetMatrix(string, XMatrix)

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

public void SetMatrix(string key, XMatrix matrix)

Parameters

key string
matrix XMatrix

SetName(string, string)

Sets the specified name value. If the value doesn’t start with a slash, it is added automatically.

public void SetName(string key, string value)

Parameters

key string
value string

SetObject(string, PdfObject)

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

public void SetObject(string key, PdfObject obj)

Parameters

key string
obj PdfObject

SetReal(string, double)

Sets the entry to a direct double value.

public void SetReal(string key, double value)

Parameters

key string
value double

SetRectangle(string, PdfRectangle)

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

public void SetRectangle(string key, PdfRectangle rect)

Parameters

key string
rect PdfRectangle

SetReference(string, PdfReference?)

Sets the entry as a reference to the specified iref.

public void SetReference(string key, PdfReference? iref)

Parameters

key string
iref PdfReference

SetReference(string, PdfObject)

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

public void SetReference(string key, PdfObject obj)

Parameters

key string
obj PdfObject

SetString(string, string)

Sets the entry to a direct string value.

public void SetString(string key, string value)

Parameters

key string
value string

SetValue(string, PdfItem)

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

public void SetValue(string key, PdfItem value)

Parameters

key string
value PdfItem

TryGetString(string, out string)

Tries to get the string. TODO: more TryGet...

public bool TryGetString(string key, out string value)

Parameters

key string
value string

Returns

bool

TryGetValue(string, out PdfItem?)

Gets the value associated with the specified key.

public bool TryGetValue(string key, out PdfItem? value)

Parameters

key string
value PdfItem

Returns

bool