public class PdfDictionary extends PdfObject
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.
ARRAY, BOOLEAN, DICTIONARY, FLUSHED, FORBID_RELEASE, FREE, INDIRECT_REFERENCE, indirectReference, LITERAL, MODIFIED, MUST_BE_FLUSHED, MUST_BE_INDIRECT, NAME, NULL, NUMBER, ORIGINAL_OBJECT_STREAM, READ_ONLY, READING, STREAM, STRING, UNENCRYPTED
Constructor and Description |
---|
PdfDictionary()
Creates a new PdfDictionary instance.
|
PdfDictionary(Map<PdfName,PdfObject> map)
Creates a new PdfDictionary instance.
|
PdfDictionary(PdfDictionary dictionary)
Creates a new PdfDictionary instance.
|
PdfDictionary(Set<Map.Entry<PdfName,PdfObject>> entrySet)
Creates a new PdfDictionary instance.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all key-value pairs from this PdfDictionary.
|
PdfDictionary |
clone(List<PdfName> excludeKeys)
Creates clones of the dictionary in the current document.
|
boolean |
containsKey(PdfName key)
Returns true if this PdfDictionary contains the specified key.
|
boolean |
containsValue(PdfObject value)
Returns true if this PdfDictionary contains the specified value.
|
protected void |
copyContent(PdfObject from, PdfDocument document)
Copies object content from object 'from'.
|
PdfDictionary |
copyTo(PdfDocument document, List<PdfName> excludeKeys, boolean allowDuplicating)
Copies dictionary to specified document.
|
Set<Map.Entry<PdfName,PdfObject>> |
entrySet()
Returns a Set holding the key-value pairs as Map#Entry objects.
|
PdfObject |
get(PdfName key)
Returns the value associated to this key.
|
PdfObject |
get(PdfName key, boolean asDirect) |
PdfArray |
getAsArray(PdfName key)
Returns the value associated to this key as a PdfArray.
|
Boolean |
getAsBool(PdfName key)
Returns the value associated to this key as a Boolean.
|
PdfBoolean |
getAsBoolean(PdfName key)
Returns the value associated to this key as a PdfBoolean.
|
PdfDictionary |
getAsDictionary(PdfName key)
Returns the value associated to this key as a PdfDictionary.
|
Float |
getAsFloat(PdfName key)
Returns the value associated to this key as a Float.
|
Integer |
getAsInt(PdfName key)
Returns the value associated to this key as an Integer.
|
PdfName |
getAsName(PdfName key)
Returns the value associated to this key as a PdfName.
|
PdfNumber |
getAsNumber(PdfName key)
Returns the value associated to this key as a PdfNumber.
|
Rectangle |
getAsRectangle(PdfName key)
Returns the value associated to this key as a Rectangle.
|
PdfStream |
getAsStream(PdfName key)
Returns the value associated to this key as a PdfStream.
|
PdfString |
getAsString(PdfName key)
Returns the value associated to this key as a PdfString.
|
byte |
getType()
Gets object type.
|
boolean |
isEmpty()
Returns true if there are no key-value pairs in this PdfDictionary.
|
Set<PdfName> |
keySet()
Returns all the keys of this PdfDictionary as a Set.
|
void |
mergeDifferent(PdfDictionary other)
This method merges different fields from two dictionaries into the current one
|
protected PdfObject |
newInstance()
Creates new instance of object.
|
PdfObject |
put(PdfName key, PdfObject value)
Inserts the value into this PdfDictionary and associates it with the specified key.
|
void |
putAll(PdfDictionary d)
Inserts all the key-value pairs into this PdfDictionary.
|
protected void |
releaseContent()
Release content of PdfDictionary.
|
PdfObject |
remove(PdfName key)
Removes the specified key from this PdfDictionary.
|
int |
size()
Returns the number of key-value pairs in this PdfDictionary.
|
String |
toString() |
Collection<PdfObject> |
values()
Returns all the values of this map in a Collection.
|
Collection<PdfObject> |
values(boolean asDirects)
Returns all the values of this map in a Collection.
|
checkState, clearState, clone, copyTo, copyTo, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isReleaseForbidden, isStream, isString, makeIndirect, makeIndirect, release, setIndirectReference, setModified, setState
public PdfDictionary()
public PdfDictionary(Map<PdfName,PdfObject> map)
map
- Map containing values to be inserted into PdfDictionary
public PdfDictionary(Set<Map.Entry<PdfName,PdfObject>> entrySet)
entrySet
- Set containing Map#Entries to be inserted into PdfDictionary
public PdfDictionary(PdfDictionary dictionary)
dictionary
- PdfDictionary containing values to be inserted into PdfDictionary
public int size()
public boolean isEmpty()
public boolean containsKey(PdfName key)
key
- the key to check
public boolean containsValue(PdfObject value)
value
- the value to check
public PdfObject get(PdfName key)
key
- the key of which the associated value needs to be returned
public PdfArray getAsArray(PdfName key)
key
- the key of which the associated value needs to be returned
public PdfDictionary getAsDictionary(PdfName key)
key
- the key of which the associated value needs to be returned
public PdfStream getAsStream(PdfName key)
key
- the key of which the associated value needs to be returned
public PdfNumber getAsNumber(PdfName key)
key
- the key of which the associated value needs to be returned
public PdfName getAsName(PdfName key)
key
- the key of which the associated value needs to be returned
public PdfString getAsString(PdfName key)
key
- the key of which the associated value needs to be returned
public PdfBoolean getAsBoolean(PdfName key)
key
- the key of which the associated value needs to be returned
public Rectangle getAsRectangle(PdfName key)
key
- the key of which the associated value needs to be returned
PdfArray.toRectangle()
public Float getAsFloat(PdfName key)
key
- the key of which the associated value needs to be returned
public Integer getAsInt(PdfName key)
key
- the key of which the associated value needs to be returned
public Boolean getAsBool(PdfName key)
key
- the key of which the associated value needs to be returned
public PdfObject put(PdfName key, PdfObject value)
key
- key to insert or to override
value
- the value to associate with the specified key
public PdfObject remove(PdfName key)
key
- key to be removed
public void putAll(PdfDictionary d)
d
- PdfDictionary holding the key-value pairs to be copied
public void clear()
public Set<PdfName> keySet()
public Collection<PdfObject> values(boolean asDirects)
asDirects
- if false, collection will contain PdfIndirectReference
instances for the indirect objects in dictionary, otherwise it will contain collection of direct objects.
public Collection<PdfObject> values()
PdfIndirectReference
instances for the indirect objects value, you shall use values(boolean)
method.
public Set<Map.Entry<PdfName,PdfObject>> entrySet()
PdfIndirectReference
instances for the indirect objects value, you shall use get(PdfName, boolean)
method.
public byte getType()
PdfObject
public PdfDictionary clone(List<PdfName> excludeKeys)
excludeKeys
- list of objects to exclude when cloning dictionary.
public PdfDictionary copyTo(PdfDocument document, List<PdfName> excludeKeys, boolean allowDuplicating)
document
- document to copy dictionary to.
excludeKeys
- list of objects to exclude when copying dictionary.
allowDuplicating
- PdfObject.copyTo(PdfDocument, boolean)
public PdfObject get(PdfName key, boolean asDirect)
asDirect
- true is to extract direct object always.
key
- the key to get the value from the map
public void mergeDifferent(PdfDictionary other)
other
- a dictionary whose fields should be merged into the current dictionary.
protected PdfObject newInstance()
PdfObject
newInstance
in class PdfObject
protected void copyContent(PdfObject from, PdfDocument document)
PdfObject
copyContent
in class PdfObject
from
- object to copy content from.
document
- document to copy object to.
protected void releaseContent()
Copyright © 1998–2023 iText Group NV. All rights reserved.