Table of Contents

Class PdfDictionary

Namespace
MiPdf.Objects
Assembly
MiPdf.dll

A PDF dictionary. The indexer returns the raw (possibly indirect) value; the typed getters (GetDictionary(PdfName), GetInt(PdfName, int), ...) resolve references transparently. Assigning null through the indexer removes the key.

public class PdfDictionary : PdfObject, IEnumerable<KeyValuePair<PdfName, PdfObject>>, IEnumerable
Inheritance
PdfDictionary
Implements
Derived
Inherited Members

Constructors

PdfDictionary()

Creates an empty dictionary.

public PdfDictionary()

PdfDictionary(PdfName)

Creates a dictionary with the /Type entry set to type.

public PdfDictionary(PdfName type)

Parameters

type PdfName

Properties

Count

The number of entries.

public int Count { get; }

Property Value

int

this[PdfName]

The raw (possibly indirect) value for key, or null if absent. Assigning null removes the entry.

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

Parameters

key PdfName

Property Value

PdfObject

Keys

The keys of all entries.

public IEnumerable<PdfName> Keys { get; }

Property Value

IEnumerable<PdfName>

ObjectType

The kind of this object.

public override PdfObjectType ObjectType { get; }

Property Value

PdfObjectType

Methods

Clear()

Removes all entries.

public void Clear()

Clone()

Creates a deep copy; references are copied as references (not followed).

public override PdfObject Clone()

Returns

PdfObject

ContainsKey(PdfName)

True if the dictionary has an entry for key.

public bool ContainsKey(PdfName key)

Parameters

key PdfName

Returns

bool

CopyEntriesTo(PdfDictionary)

Copies deep clones of all entries into target, replacing entries with the same key.

protected void CopyEntriesTo(PdfDictionary target)

Parameters

target PdfDictionary

Get(PdfName)

Returns the resolved value for key, or null if absent or the null object.

public PdfObject? Get(PdfName key)

Parameters

key PdfName

Returns

PdfObject

GetArray(PdfName)

Returns the resolved value if it is an array, otherwise null.

public PdfArray? GetArray(PdfName key)

Parameters

key PdfName

Returns

PdfArray

GetBool(PdfName, bool)

Returns the resolved boolean, or defaultValue if it is missing or not a boolean.

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

Parameters

key PdfName
defaultValue bool

Returns

bool

GetDictionary(PdfName)

Returns the resolved value if it is a dictionary (or stream), otherwise null.

public PdfDictionary? GetDictionary(PdfName key)

Parameters

key PdfName

Returns

PdfDictionary

GetDouble(PdfName, double)

Returns the resolved number, or defaultValue if it is missing or not a number.

public double GetDouble(PdfName key, double defaultValue = 0)

Parameters

key PdfName
defaultValue double

Returns

double

GetEnumerator()

Enumerates the entries with their raw (unresolved) values.

public IEnumerator<KeyValuePair<PdfName, PdfObject>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<PdfName, PdfObject>>

GetInt(PdfName, int)

Returns the resolved number as int (see IntValue), or defaultValue if it is missing or not a number.

public int GetInt(PdfName key, int defaultValue = 0)

Parameters

key PdfName
defaultValue int

Returns

int

GetLong(PdfName, long)

Returns the resolved number as long (see LongValue), or defaultValue if it is missing or not a number.

public long GetLong(PdfName key, long defaultValue = 0)

Parameters

key PdfName
defaultValue long

Returns

long

GetName(PdfName)

Returns the resolved value if it is a name, otherwise null.

public PdfName? GetName(PdfName key)

Parameters

key PdfName

Returns

PdfName

GetNumber(PdfName)

Returns the resolved value if it is a number, otherwise null.

public PdfNumber? GetNumber(PdfName key)

Parameters

key PdfName

Returns

PdfNumber

GetRectangle(PdfName)

Returns the value as normalized rectangle (see ToRectangle()), or null if it is not an array of at least four elements.

public PdfRectangle? GetRectangle(PdfName key)

Parameters

key PdfName

Returns

PdfRectangle?

GetStream(PdfName)

Returns the resolved value if it is a stream, otherwise null.

public PdfStream? GetStream(PdfName key)

Parameters

key PdfName

Returns

PdfStream

GetString(PdfName)

Returns the resolved value if it is a string, otherwise null.

public PdfString? GetString(PdfName key)

Parameters

key PdfName

Returns

PdfString

GetText(PdfName)

Returns the decoded text of a string value (or the name value of a name).

public string? GetText(PdfName key)

Parameters

key PdfName

Returns

string

Get<T>(PdfName)

Returns the resolved value for key if it is a T, otherwise null.

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

Parameters

key PdfName

Returns

T

Type Parameters

T

IsType(PdfName)

Checks the /Type entry.

public bool IsType(PdfName type)

Parameters

type PdfName

Returns

bool

Remove(PdfName)

Removes the entry for key; returns false if there was none.

public bool Remove(PdfName key)

Parameters

key PdfName

Returns

bool

Set(PdfName, PdfObject?)

Sets the value for key; null removes the entry.

public void Set(PdfName key, PdfObject? value)

Parameters

key PdfName
value PdfObject

Set(PdfName, bool)

Sets a boolean value.

public void Set(PdfName key, bool value)

Parameters

key PdfName
value bool

Set(PdfName, double)

Sets a real value.

public void Set(PdfName key, double value)

Parameters

key PdfName
value double

Set(PdfName, int)

Sets an integer value.

public void Set(PdfName key, int value)

Parameters

key PdfName
value int

Set(PdfName, long)

Sets an integer value.

public void Set(PdfName key, long value)

Parameters

key PdfName
value long

SetName(PdfName, string?)

Sets a name value (a leading slash is ignored); null removes the entry.

public void SetName(PdfName key, string? value)

Parameters

key PdfName
value string

SetText(PdfName, string?)

Sets a text string value.

public void SetText(PdfName key, string? value)

Parameters

key PdfName
value string