Class PdfDictionary
A representation of a Dictionary as described by the PDF Specification.
public class PdfDictionary : PdfObject
- Inheritance
-
PdfDictionary
- Derived
- Inherited Members
- Extension Methods
Remarks
A representation of a Dictionary as described by the PDF Specification. A Dictionary is a mapping between keys and values. Keys are PdfNames and the values are PdfObjects . Each key can only be associated with one value and adding a new value to an existing key will override the previous value. A value of null should be ignored when the PdfDocument is closed.
Constructors
PdfDictionary()
Creates a new PdfDictionary instance.
public PdfDictionary()
PdfDictionary(ICollection<KeyValuePair<PdfName, PdfObject>>)
Creates a new PdfDictionary instance.
public PdfDictionary(ICollection<KeyValuePair<PdfName, PdfObject>> entrySet)
Parameters
entrySet
ICollection<KeyValuePair<PdfName, PdfObject>>Set containing Map#Entries to be inserted into PdfDictionary
Remarks
Creates a new PdfDictionary instance. This constructor inserts the content of the specified Set into this PdfDictionary instance.
PdfDictionary(IDictionary<PdfName, PdfObject>)
Creates a new PdfDictionary instance.
public PdfDictionary(IDictionary<PdfName, PdfObject> map)
Parameters
map
IDictionary<PdfName, PdfObject>Map containing values to be inserted into PdfDictionary
Remarks
Creates a new PdfDictionary instance. This constructor inserts the content of the specified Map into this PdfDictionary instance.
PdfDictionary(PdfDictionary)
Creates a new PdfDictionary instance.
public PdfDictionary(PdfDictionary dictionary)
Parameters
dictionary
PdfDictionaryPdfDictionary containing values to be inserted into PdfDictionary
Remarks
Creates a new PdfDictionary instance. This constructor inserts the content of the specified PdfDictionary into this PdfDictionary instance.
Methods
Clear()
Removes all key-value pairs from this PdfDictionary.
public virtual void Clear()
Clone(IList<PdfName>)
Creates clones of the dictionary in the current document.
public virtual PdfDictionary Clone(IList<PdfName> excludeKeys)
Parameters
Returns
- PdfDictionary
cloned dictionary.
Remarks
Creates clones of the dictionary in the current document. It's possible to pass a list of keys to exclude when cloning.
ContainsKey(PdfName)
Returns true if this PdfDictionary contains the specified key.
public virtual bool ContainsKey(PdfName key)
Parameters
key
PdfNamethe key to check
Returns
- bool
true if key is present in the PdfDictionary
ContainsValue(PdfObject)
Returns true if this PdfDictionary contains the specified value.
public virtual bool ContainsValue(PdfObject value)
Parameters
value
PdfObjectthe value to check
Returns
- bool
true if value is present in the PdfDictionary
CopyContent(PdfObject, PdfDocument)
protected override void CopyContent(PdfObject from, PdfDocument document)
Parameters
from
PdfObjectdocument
PdfDocument
CopyContent(PdfObject, PdfDocument, ICopyFilter)
protected override void CopyContent(PdfObject from, PdfDocument document, ICopyFilter copyFilter)
Parameters
from
PdfObjectdocument
PdfDocumentcopyFilter
ICopyFilter
CopyTo(PdfDocument, IList<PdfName>, bool)
Copies dictionary to specified document.
public virtual PdfDictionary CopyTo(PdfDocument document, IList<PdfName> excludeKeys, bool allowDuplicating)
Parameters
document
PdfDocumentdocument to copy dictionary to.
excludeKeys
IList<PdfName>list of objects to exclude when copying dictionary.
allowDuplicating
bool
Returns
- PdfDictionary
copied dictionary.
Remarks
Copies dictionary to specified document. It's possible to pass a list of keys to exclude when copying.
CopyTo(PdfDocument, IList<PdfName>, bool, ICopyFilter)
Copies dictionary to specified document.
public virtual PdfDictionary CopyTo(PdfDocument document, IList<PdfName> excludeKeys, bool allowDuplicating, ICopyFilter copyFilter)
Parameters
document
PdfDocumentdocument to copy dictionary to.
excludeKeys
IList<PdfName>list of objects to exclude when copying dictionary.
allowDuplicating
boolcopyFilter
ICopyFilterICopyFilter a filter to apply while copying arrays and dictionaries Use NullCopyFilter for no filtering
Returns
- PdfDictionary
copied dictionary.
Remarks
Copies dictionary to specified document. It's possible to pass a list of keys to exclude when copying.
EntrySet()
Returns a Set holding the key-value pairs as Map#Entry objects.
public virtual ICollection<KeyValuePair<PdfName, PdfObject>> EntrySet()
Returns
- ICollection<KeyValuePair<PdfName, PdfObject>>
a Set of Map.Entry objects
Remarks
Returns a Set holding the key-value pairs as Map#Entry objects.
NOTE: since 7.0.1 it returns collection of direct objects.
If you want to get
PdfIndirectReference
instances for the indirect objects value,
you shall use
Get(PdfName, bool)
method.
Get(PdfName)
Returns the value associated to this key.
public virtual PdfObject Get(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- PdfObject
the value associated with this key
Get(PdfName, bool)
public virtual PdfObject Get(PdfName key, bool asDirect)
Parameters
key
PdfNamethe key to get the value from the map
asDirect
booltrue is to extract direct object always.
Returns
- PdfObject
key if indirect reference is present
GetAsArray(PdfName)
Returns the value associated to this key as a PdfArray.
public virtual PdfArray GetAsArray(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- PdfArray
PdfArray associated with this key
Remarks
Returns the value associated to this key as a PdfArray. If the value isn't a PdfArray, null is returned.
GetAsBool(PdfName)
Returns the value associated to this key as a Boolean.
public virtual bool? GetAsBool(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- bool?
Boolean associated with this key
Remarks
Returns the value associated to this key as a Boolean. If the value isn't a PdfBoolean, null is returned.
GetAsBoolean(PdfName)
Returns the value associated to this key as a PdfBoolean.
public virtual PdfBoolean GetAsBoolean(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- PdfBoolean
PdfBoolean associated with this key
Remarks
Returns the value associated to this key as a PdfBoolean. If the value isn't a PdfBoolean, null is returned.
GetAsDictionary(PdfName)
Returns the value associated to this key as a PdfDictionary.
public virtual PdfDictionary GetAsDictionary(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- PdfDictionary
PdfDictionary associated with this key
Remarks
Returns the value associated to this key as a PdfDictionary. If the value isn't a PdfDictionary, null is returned.
GetAsFloat(PdfName)
Returns the value associated to this key as a Float.
public virtual float? GetAsFloat(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- float?
Float associated with this key
Remarks
Returns the value associated to this key as a Float. If the value isn't a Pdfnumber, null is returned.
GetAsInt(PdfName)
Returns the value associated to this key as an Integer.
public virtual int? GetAsInt(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- int?
Integer associated with this key
Remarks
Returns the value associated to this key as an Integer. If the value isn't a Pdfnumber, null is returned.
GetAsName(PdfName)
Returns the value associated to this key as a PdfName.
public virtual PdfName GetAsName(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- PdfName
PdfName associated with this key
Remarks
Returns the value associated to this key as a PdfName. If the value isn't a PdfName, null is returned.
GetAsNumber(PdfName)
Returns the value associated to this key as a PdfNumber.
public virtual PdfNumber GetAsNumber(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- PdfNumber
PdfNumber associated with this key
Remarks
Returns the value associated to this key as a PdfNumber. If the value isn't a PdfNumber, null is returned.
GetAsRectangle(PdfName)
Returns the value associated to this key as a Rectangle.
public virtual Rectangle GetAsRectangle(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- Rectangle
PdfArray associated with this key
Remarks
Returns the value associated to this key as a Rectangle. If the value isn't a PdfArray of which the firt four elements are PdfNumbers, null is returned.
- See Also
GetAsStream(PdfName)
Returns the value associated to this key as a PdfStream.
public virtual PdfStream GetAsStream(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- PdfStream
PdfStream associated with this key
Remarks
Returns the value associated to this key as a PdfStream. If the value isn't a PdfStream, null is returned.
GetAsString(PdfName)
Returns the value associated to this key as a PdfString.
public virtual PdfString GetAsString(PdfName key)
Parameters
key
PdfNamethe key of which the associated value needs to be returned
Returns
- PdfString
PdfString associated with this key
Remarks
Returns the value associated to this key as a PdfString. If the value isn't a PdfString, null is returned.
GetObjectType()
public override byte GetObjectType()
Returns
IsEmpty()
Returns true if there are no key-value pairs in this PdfDictionary.
public virtual bool IsEmpty()
Returns
- bool
true if there are no key-value pairs in this PdfDictionary
KeySet()
Returns all the keys of this PdfDictionary as a Set.
public virtual ICollection<PdfName> KeySet()
Returns
- ICollection<PdfName>
Set of keys
MergeDifferent(PdfDictionary)
This method merges different fields from two dictionaries into the current one
public virtual void MergeDifferent(PdfDictionary other)
Parameters
other
PdfDictionarya dictionary whose fields should be merged into the current dictionary.
NewInstance()
protected override PdfObject NewInstance()
Returns
Put(PdfName, PdfObject)
Inserts the value into this PdfDictionary and associates it with the specified key.
public virtual PdfObject Put(PdfName key, PdfObject value)
Parameters
key
PdfNamekey to insert or to override
value
PdfObjectthe value to associate with the specified key
Returns
- PdfObject
the previous PdfObject associated with this key
Remarks
Inserts the value into this PdfDictionary and associates it with the specified key. If the key is already present in this PdfDictionary, this method will override the old value with the specified one.
PutAll(PdfDictionary)
Inserts all the key-value pairs into this PdfDictionary.
public virtual void PutAll(PdfDictionary d)
Parameters
d
PdfDictionaryPdfDictionary holding the key-value pairs to be copied
ReleaseContent()
Release content of PdfDictionary.
protected virtual void ReleaseContent()
Remove(PdfName)
Removes the specified key from this PdfDictionary.
public virtual PdfObject Remove(PdfName key)
Parameters
key
PdfNamekey to be removed
Returns
- PdfObject
the removed value associated with the specified key
Size()
Returns the number of key-value pairs in this PdfDictionary.
public virtual int Size()
Returns
- int
number of key-value pairs
ToString()
public override string ToString()
Returns
Values()
Returns all the values of this map in a Collection.
public virtual ICollection<PdfObject> Values()
Returns
- ICollection<PdfObject>
a Collection holding all the values
Remarks
Returns all the values of this map in a Collection.
NOTE: since 7.0.1 it returns collection of direct objects.
If you want to get
PdfIndirectReference
instances for the indirect objects value,
you shall use
Values(bool)
method.
Values(bool)
Returns all the values of this map in a Collection.
public virtual ICollection<PdfObject> Values(bool asDirects)
Parameters
asDirects
boolif false, collection will contain PdfIndirectReference instances for the indirect objects in dictionary, otherwise it will contain collection of direct objects.
Returns
- ICollection<PdfObject>
a Collection holding all the values