PdfDictionary Class

A dictionary: entries whose keys are names (ISO 32000-2, 7.3.7). It keeps the order of its entries, and is mutable and not thread-safe.

public sealed class PdfDictionary : PdfObject, IEnumerable<KeyValuePair<PdfName, PdfObject>>, IEnumerable

Remarks

The indexer gets the values as they are stored: a value may be a PdfReference. The Get* and TryGetResolved methods resolve them, and treat a null value as an absent entry, as the specification does.

Inheritance
PdfObject PdfDictionary
Implements

Constructors

NameDescription
PdfDictionary()Initializes a new instance of the PdfDictionary class.
PdfDictionary(int)Initializes a new instance of the PdfDictionary class with a capacity.

PdfDictionary overloads

PdfDictionary()

PdfDictionary.cs

Initializes a new instance of the PdfDictionary class.

public PdfDictionary()

PdfDictionary(int)

PdfDictionary.cs

Initializes a new instance of the PdfDictionary class with a capacity.

public PdfDictionary(int capacity)
Parameters
capacity int
The initial capacity.

Properties

NameDescription
CountGets the number of entries.
KeysGets the keys, in the order of the entries.
KindGets the kind of the object.

Gets the number of entries.

public int Count { get; }

Property value

int

Gets the keys, in the order of the entries.

public IEnumerable<PdfName> Keys { get; }

Property value

IEnumerable<PdfName>

Gets the kind of the object.

public override PdfObjectKind Kind { get; }

Property value

PdfObjectKind

Indexers

NameDescription
this[PdfName]Gets or sets the value of an entry, as it is stored: it may be a PdfReference.

this[PdfName]

PdfDictionary.cs

Gets or sets the value of an entry, as it is stored: it may be a PdfReference.

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

Parameters

key PdfName
The key.

Property value

PdfObject?

Methods

NameDescription
Clear()Removes every entry.
CloneShallow()Copies the entries of the dictionary to a new dictionary. The values are not copied.
ContainsKey(PdfName)Indicates whether the dictionary has an entry.
Get<T>(PdfName)Gets the resolved value of an entry when it has a type.
GetBoolean(PdfName, bool)Gets the value of an entry as a boolean.
GetEnumerator()Returns an enumerator over the entries, whose values are not resolved.
GetInteger(PdfName, long)Gets the value of an entry as an integer. A real number is truncated.
GetName(PdfName)Gets the value of an entry as a name.
GetNumber(PdfName, double)Gets the value of an entry as a number.
GetResolved(PdfName)Gets the value of an entry, resolving it when it is a reference.
GetText(PdfName)Gets the value of an entry as a text string (ISO 32000-2, 7.9.2.2).
IsType(PdfName)Indicates whether the value of the /Type entry is a name.
Remove(PdfName)Removes an entry.
SetName(PdfName, string)Sets an entry to a name.
SetNumber(PdfName, double)Sets an entry to a number: an integer when the value is a whole number, a real number otherwise.
SetText(PdfName, string?)Sets an entry to a text string (ISO 32000-2, 7.9.2.2), or removes it when the text is null.
System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<Meziantou.Framework.Pdf.Objects.PdfName,Meziantou.Framework.Pdf.Objects.PdfObject>>.GetEnumerator()
System.Collections.IEnumerable.GetEnumerator()
TryGetResolved<T>(PdfName, T?)Gets the value of an entry, resolved, when it has a type.

Removes every entry.

public void Clear()

CloneShallow()

PdfDictionary.cs

Copies the entries of the dictionary to a new dictionary. The values are not copied.

public PdfDictionary CloneShallow()

Returns

PdfDictionary The copy.

ContainsKey(PdfName)

PdfDictionary.cs

Indicates whether the dictionary has an entry.

public bool ContainsKey(PdfName key)

Parameters

key PdfName
The key.

Returns

bool true when there is an entry, whatever its value.

Get<T>(PdfName)

PdfDictionary.cs

Gets the resolved value of an entry when it has a type.

public T? Get<T>(PdfName key) where T : PdfObject

Type parameters

T
The type of the value.

Parameters

key PdfName
The key.

Returns

T? The value, or null when there is no entry or when it has another type.

GetBoolean(PdfName, bool)

PdfDictionary.cs

Gets the value of an entry as a boolean.

public bool GetBoolean(PdfName key, bool defaultValue = false)

Parameters

key PdfName
The key.
defaultValue bool
The value when there is no boolean.

Returns

bool The boolean.

GetEnumerator()

PdfDictionary.cs

Returns an enumerator over the entries, whose values are not resolved.

GetInteger(PdfName, long)

PdfDictionary.cs

Gets the value of an entry as an integer. A real number is truncated.

public long GetInteger(PdfName key, long defaultValue = 0L)

Parameters

key PdfName
The key.
defaultValue long
The value when there is no number.

Returns

long The integer.

GetName(PdfName)

PdfDictionary.cs

Gets the value of an entry as a name.

public PdfName? GetName(PdfName key)

Parameters

key PdfName
The key.

Returns

PdfName? The name, or null when the value is not a name.

GetNumber(PdfName, double)

PdfDictionary.cs

Gets the value of an entry as a number.

public double GetNumber(PdfName key, double defaultValue = 0d)

Parameters

key PdfName
The key.
defaultValue double
The value when there is no number.

Returns

double The number.

GetResolved(PdfName)

PdfDictionary.cs

Gets the value of an entry, resolving it when it is a reference.

public PdfObject? GetResolved(PdfName key)

Parameters

key PdfName
The key.

Returns

PdfObject? The value, or null when there is no entry, when the value is null, or when it is a reference to an object that does not exist.

GetText(PdfName)

PdfDictionary.cs

Gets the value of an entry as a text string (ISO 32000-2, 7.9.2.2).

public string? GetText(PdfName key)

Parameters

key PdfName
The key.

Returns

string? The text, or null when the value is not a string.

IsType(PdfName)

PdfDictionary.cs

Indicates whether the value of the /Type entry is a name.

public bool IsType(PdfName type)

Parameters

type PdfName
The name.

Returns

bool true when the type is the name.

Remove(PdfName)

PdfDictionary.cs

Removes an entry.

public bool Remove(PdfName key)

Parameters

key PdfName
The key.

Returns

bool true when the entry existed.

SetName(PdfName, string)

PdfDictionary.cs

Sets an entry to a name.

public void SetName(PdfName key, string value)

Parameters

key PdfName
The key.
value string
The name.

SetNumber(PdfName, double)

PdfDictionary.cs

Sets an entry to a number: an integer when the value is a whole number, a real number otherwise.

public void SetNumber(PdfName key, double value)

Parameters

key PdfName
The key.
value double
The number.

SetText(PdfName, string?)

PdfDictionary.cs

Sets an entry to a text string (ISO 32000-2, 7.9.2.2), or removes it when the text is null.

public void SetText(PdfName key, string? value)

Parameters

key PdfName
The key.
value string?
The text.

System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<Meziantou.Framework.Pdf.Objects.PdfName,Meziantou.Framework.Pdf.Objects.PdfObject>>.GetEnumerator()

PdfDictionary.cs

System.Collections.IEnumerable.GetEnumerator()

PdfDictionary.cs
IEnumerator IEnumerable.GetEnumerator()

No documentation is available.

TryGetResolved<T>(PdfName, T?)

PdfDictionary.cs

Gets the value of an entry, resolved, when it has a type.

public bool TryGetResolved<T>(PdfName key, out T? value) where T : PdfObject

Type parameters

T
The type of the value.

Parameters

key PdfName
The key.
value T?
The value.

Returns

bool true when the resolved value has the type.