Class PdfDictionary
- Direct Known Subclasses:
PdfAction,PdfAnnotation,PdfDocument.PdfInfo,PdfGState,PdfPage,PdfResources,PdfStream
PdfDictionary is the Pdf dictionary object.
A dictionary is an associative table containing pairs of objects. The first element of each pair is called the
key and the second element is called the value. Unlike dictionaries in the PostScript language, a key
must be a
PdfName.
A value can be any kind of PdfObject, including a dictionary. A dictionary is generally used to collect
and tie together the attributes of a complex object, with each key-value pair specifying the name and value of an
attribute.
A dictionary is represented by two left angle brackets (<<), followed by a sequence of
key-value pairs, followed by two right angle brackets (>>).
This object is described in the 'Portable
Document Format Reference Manual version 1.7' section 3.2.6 (page 59-60).
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PdfNameThis is a possible type of dictionarystatic final PdfNameThis is a possible type of dictionaryThis is the hashmap that contains all the values and keys of the dictionarystatic final PdfNameThis is a possible type of dictionarystatic final PdfNameThis is a possible type of dictionarystatic final PdfNameThis is a possible type of dictionaryFields inherited from class org.openpdf.text.pdf.PdfObject
ARRAY, BOOLEAN, bytes, DICTIONARY, INDIRECT, NAME, NOTHING, NULL, NUMBER, STREAM, STRING, TEXT_PDFDOCENCODING, TEXT_UNICODE, type -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyPdfDictionary-object.PdfDictionary(PdfName type) Constructs aPdfDictionary-object of a certain type. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturnstrueif thisPdfDictionarycontains a mapping for the specified key.Returns thePdfObjectassociated to the specified key.Returns aPdfObjectas aPdfDictionary, resolving indirect references.getDirectObject(PdfName key) Returns thePdfObjectassociated to the specified key, resolving a possible indirect reference to a direct object.getKeys()Get all keys that are set.voidmerge(PdfDictionary other) voidmergeDifferent(PdfDictionary other) voidAssociates the specifiedPdfObjectas value with the specifiedPdfNameas key in this map.voidputAll(PdfDictionary dic) Copies all of the mappings from the specifiedPdfDictionaryto thisPdfDictionary.voidAssociates the specifiedPdfObjectas value to the specifiedPdfNameas key in this map.voidRemoves aPdfObjectand its key from thePdfDictionary.intsize()Returns the number of key-value mappings in thisPdfDictionary.voidtoPdf(PdfWriter writer, OutputStream os) Writes the PDF representation of thisPdfDictionaryas an array ofbyteto the givenOutputStream.toString()Returns a string representation of thisPdfDictionary.Methods inherited from class org.openpdf.text.pdf.PdfObject
canBeInObjStm, getBytes, isArray, isDictionary, isName, isNull, isNumber, isString, setContent, type
-
Field Details
-
FONT
This is a possible type of dictionary -
OUTLINES
This is a possible type of dictionary -
PAGE
This is a possible type of dictionary -
PAGES
This is a possible type of dictionary -
CATALOG
This is a possible type of dictionary -
hashMap
This is the hashmap that contains all the values and keys of the dictionary
-
-
Constructor Details
-
PdfDictionary
public PdfDictionary()Constructs an emptyPdfDictionary-object. -
PdfDictionary
Constructs aPdfDictionary-object of a certain type.- Parameters:
type- aPdfName
-
-
Method Details
-
toPdf
Writes the PDF representation of thisPdfDictionaryas an array ofbyteto the givenOutputStream.- Overrides:
toPdfin classPdfObject- Parameters:
writer- for backwards compatibilityos- theOutputStreamto write the bytes to.- Throws:
IOException- on error
-
toString
Returns a string representation of thisPdfDictionary.The string doesn't contain any of the content of this dictionary. Rather the string "dictionary" is returned, possibly followed by the type of this
PdfDictionary, if set. -
put
Associates the specifiedPdfObjectas value with the specifiedPdfNameas key in this map.If the map previously contained a mapping for this key, the old value is replaced. If the value is
nullorPdfNullthe key is deleted.- Parameters:
key- aPdfNameobject- thePdfObjectto be associated with the key
-
putEx
Associates the specifiedPdfObjectas value to the specifiedPdfNameas key in this map.If the value is a
PdfNull, it is treated just as any otherPdfObject. If the value isnullhowever nothing is done.- Parameters:
key- aPdfNamevalue- thePdfObjectto be associated to the key
-
putAll
Copies all of the mappings from the specifiedPdfDictionaryto thisPdfDictionary.These mappings will replace any mappings previously contained in this
PdfDictionary.- Parameters:
dic- ThePdfDictionarywith the mappings to be copied over
-
remove
Removes aPdfObjectand its key from thePdfDictionary.- Parameters:
key- aPdfName
-
get
Returns thePdfObjectassociated to the specified key.- Parameters:
key- aPdfName- Returns:
- the
PdfObjectpreviously associated to the key
-
getKeys
Get all keys that are set.- Returns:
trueif it is, otherwisefalse.
-
size
public int size()Returns the number of key-value mappings in thisPdfDictionary.- Returns:
- the number of key-value mappings in this
PdfDictionary.
-
contains
Returnstrueif thisPdfDictionarycontains a mapping for the specified key.- Parameters:
key- key- Returns:
trueif the key is set, otherwisefalse.
-
merge
-
mergeDifferent
-
getDirectObject
Returns thePdfObjectassociated to the specified key, resolving a possible indirect reference to a direct object.This method will never return a
PdfIndirectReferenceobject.- Parameters:
key- A key for thePdfObjectto be returned- Returns:
- A direct
PdfObjectornull
-
getAsDict
Returns aPdfObjectas aPdfDictionary, resolving indirect references.The object associated with the
PdfNamegiven is retrieved and resolved to a direct object. If it is aPdfDictionary, it is cast down and returned as such. Otherwisenullis returned.- Parameters:
key- APdfName- Returns:
- the associated
PdfDictionaryobject, ornull
-