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)
Copies object to a specified document.
|
PdfDictionary |
copyTo(PdfDocument document, boolean allowDuplicating)
Copies object to a specified document.
|
PdfDictionary |
copyTo(PdfDocument document, List<PdfName> excludeKeys, boolean allowDuplicating)
Copies dictionary to specified document.
|
Set<Map.Entry<PdfName,PdfObject>> |
directEntrySet()
Deprecated.
Use
entrySet() instead.
|
Collection<PdfObject> |
directValues()
Deprecated.
Use
values() instead.
|
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.
|
PdfDictionary |
makeIndirect(PdfDocument document)
Marks object to be saved as indirect.
|
PdfDictionary |
makeIndirect(PdfDocument document, PdfIndirectReference reference)
Marks object to be saved as indirect.
|
void |
mergeDifferent(PdfDictionary other)
This method merges different fields from two dictionaries into the current one
|
protected PdfDictionary |
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, flush, flush, getIndirectReference, isArray, isBoolean, isDictionary, isFlushed, isIndirect, isIndirectReference, isLiteral, isModified, isName, isNull, isNumber, isStream, isString, 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.
@Deprecated public Collection<PdfObject> directValues()
values()
instead.
values()
method, this method will resolve all indirect references in the dictionary and return actual objects in collection.
public Set<Map.Entry<PdfName,PdfObject>> entrySet()
PdfIndirectReference
instances for the indirect objects value, you shall use get(PdfName, boolean)
method.
@Deprecated public Set<Map.Entry<PdfName,PdfObject>> directEntrySet()
entrySet()
instead.
entrySet()
method, this method will resolve all indirect references in the dictionary and return actual objects as values of entries in the collection.
public byte getType()
PdfObject
public PdfDictionary clone(List<PdfName> excludeKeys)
excludeKeys
- list of objects to exclude when cloning dictionary.
public PdfDictionary makeIndirect(PdfDocument document)
makeIndirect
in class PdfObject
document
- a document the indirect reference will belong to.
public PdfDictionary makeIndirect(PdfDocument document, PdfIndirectReference reference)
makeIndirect
in class PdfObject
document
- a document the indirect reference will belong to.
public PdfDictionary copyTo(PdfDocument document)
public PdfDictionary copyTo(PdfDocument document, boolean allowDuplicating)
copyTo
in class PdfObject
document
- document to copy object to.
allowDuplicating
- indicates if to allow copy objects which already have been copied. If object is associated with any indirect reference and allowDuplicating is false then already existing reference will be returned instead of copying object. If allowDuplicating is true then object will be copied and new indirect reference will be assigned.
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.
public void mergeDifferent(PdfDictionary other)
other
- a dictionary whose fields should be merged into the current dictionary.
protected PdfDictionary 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–2018 iText Group NV. All rights reserved.