Class PdfDictionary
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CoordinateSystem
,CuePoint
,Measure
,NumberFormatDictionary
,PdfAcroForm
,PdfAction
,PdfAnnotation
,PdfBorderDictionary
,PdfCollection
,PdfCollectionField
,PdfCollectionItem
,PdfCollectionSchema
,PdfCollectionSort
,PdfContentStreamProcessor.ResourceDictionary
,PdfDocument.PdfCatalog
,PdfDocument.PdfInfo
,PdfFileSpecification
,PdfGState
,PdfLayer
,PdfLayerMembership
,PdfMediaClipData
,PdfOCProperties
,PdfOutline
,PdfPage
,PdfRendition
,PdfResources
,PdfShadingPattern
,PdfSigLockDictionary
,PdfSignature
,PdfSignatureAppDictionary
,PdfSignatureBuildProperties
,PdfStream
,PdfStructureElement
,PdfStructureTreeRoot
,PdfTargetDictionary
,PdfTransparencyGroup
,PdfWriter.PdfTrailer
,PointData
,PRAcroForm
,RichMediaActivation
,RichMediaAnimation
,RichMediaCommand
,RichMediaConfiguration
,RichMediaDeactivation
,RichMediaInstance
,RichMediaParams
,RichMediaPosition
,RichMediaPresentation
,RichMediaWindow
,Viewport
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 (invalid input: '<'invalid input: '<'), 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 PdfName
This is a possible type of dictionaryprivate PdfName
This is the type of this dictionarystatic final PdfName
This is a possible type of dictionaryprotected LinkedHashMap
<PdfName, PdfObject> This is the hashmap that contains all the values and keys of the dictionarystatic final PdfName
This is a possible type of dictionarystatic final PdfName
This is a possible type of dictionarystatic final PdfName
This is a possible type of dictionary -
Constructor Summary
ConstructorsConstructorDescriptionConstructs an emptyPdfDictionary
-object.PdfDictionary
(int capacity) PdfDictionary
(PdfName type) Constructs aPdfDictionary
-object of a certain type. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks the type of the dictionary.void
clear()
Removes all thePdfObject
s and its keys from thePdfDictionary
.boolean
Returnstrue
if thisPdfDictionary
contains a mapping for the specified key.Returns thePdfObject
associated to the specified key.getAsArray
(PdfName key) Returns aPdfObject
as aPdfArray
, resolving indirect references.getAsBoolean
(PdfName key) Returns aPdfObject
as aPdfBoolean
, resolving indirect references.Returns aPdfObject
as aPdfDictionary
, resolving indirect references.Returns aPdfObject
as aPdfIndirectReference
.Returns aPdfObject
as aPdfName
, resolving indirect references.getAsNumber
(PdfName key) Returns aPdfObject
as aPdfNumber
, resolving indirect references.getAsStream
(PdfName key) Returns aPdfObject
as aPdfStream
, resolving indirect references.getAsString
(PdfName key) Returns aPdfObject
as aPdfString
, resolving indirect references.getDirectObject
(PdfName key) Returns thePdfObject
associated to the specified key, resolving a possible indirect reference to a direct object.getKeys()
Get all keys that are set.boolean
Checks if aDictionary
is of the type CATALOG.boolean
isFont()
Checks if aDictionary
is of the type FONT.boolean
Checks if aDictionary
is of the type OUTLINES.boolean
isPage()
Checks if aDictionary
is of the type PAGE.boolean
isPages()
Checks if aDictionary
is of the type PAGES.void
merge
(PdfDictionary other) void
mergeDifferent
(PdfDictionary other) void
Associates the specifiedPdfObject
as value with the specifiedPdfName
as key in this map.void
putAll
(PdfDictionary dic) Copies all of the mappings from the specifiedPdfDictionary
to thisPdfDictionary
.void
Associates the specifiedPdfObject
as value to the specifiedPdfName
as key in this map.void
Removes aPdfObject
and its key from thePdfDictionary
.int
size()
Returns the number of key-value mappings in thisPdfDictionary
.void
toPdf
(PdfWriter writer, OutputStream os) Writes the PDF representation of thisPdfDictionary
as an array ofbyte
to the givenOutputStream
.toString()
Returns a string representation of thisPdfDictionary
.Methods inherited from class com.itextpdf.text.pdf.PdfObject
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, 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 -
dictionaryType
This is the type of this 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
public PdfDictionary(int capacity) -
PdfDictionary
Constructs aPdfDictionary
-object of a certain type.- Parameters:
type
- aPdfName
-
-
Method Details
-
toPdf
Writes the PDF representation of thisPdfDictionary
as an array ofbyte
to the givenOutputStream
.- Overrides:
toPdf
in classPdfObject
- Parameters:
writer
- for backwards compatibilityos
- theOutputStream
to write the bytes to.- Throws:
IOException
-
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 thisPdfDictionary
, if set. -
put
Associates the specifiedPdfObject
as value with the specifiedPdfName
as key in this map. If the map previously contained a mapping for this key, the old value is replaced. If the value isnull
orPdfNull
the key is deleted.- Parameters:
key
- aPdfName
object
- thePdfObject
to be associated with the key
-
putEx
Associates the specifiedPdfObject
as value to the specifiedPdfName
as key in this map. If the value is aPdfNull
, it is treated just as any otherPdfObject
. If the value isnull
however nothing is done.- Parameters:
key
- aPdfName
value
- thePdfObject
to be associated to the key
-
putAll
Copies all of the mappings from the specifiedPdfDictionary
to thisPdfDictionary
. These mappings will replace any mappings previously contained in thisPdfDictionary
.- Parameters:
dic
- ThePdfDictionary
with the mappings to be copied over
-
remove
Removes aPdfObject
and its key from thePdfDictionary
.- Parameters:
key
- aPdfName
-
clear
public void clear()Removes all thePdfObject
s and its keys from thePdfDictionary
.- Since:
- 5.0.2
-
get
Returns thePdfObject
associated to the specified key.- Parameters:
key
- aPdfName
- Returns:
- the PdfObject previously associated to the key
-
getDirectObject
Returns thePdfObject
associated to the specified key, resolving a possible indirect reference to a direct object. This method will never return aPdfIndirectReference
object.- Parameters:
key
- A key for thePdfObject
to be returned- Returns:
- A direct
PdfObject
ornull
-
getKeys
Get all keys that are set.- Returns:
true
if 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
Returnstrue
if thisPdfDictionary
contains a mapping for the specified key.- Returns:
true
if the key is set, otherwisefalse
.
-
isFont
public boolean isFont()Checks if aDictionary
is of the type FONT.- Returns:
true
if it is, otherwisefalse
.
-
isPage
public boolean isPage()Checks if aDictionary
is of the type PAGE.- Returns:
true
if it is, otherwisefalse
.
-
isPages
public boolean isPages()Checks if aDictionary
is of the type PAGES.- Returns:
true
if it is, otherwisefalse
.
-
isCatalog
public boolean isCatalog()Checks if aDictionary
is of the type CATALOG.- Returns:
true
if it is, otherwisefalse
.
-
isOutlineTree
public boolean isOutlineTree()Checks if aDictionary
is of the type OUTLINES.- Returns:
true
if it is, otherwisefalse
.
-
checkType
Checks the type of the dictionary.- Parameters:
type
- the type you're looking for- Returns:
- true if the type of the dictionary corresponds with the type you're looking for
-
merge
-
mergeDifferent
-
getAsDict
Returns aPdfObject
as aPdfDictionary
, resolving indirect references. The object associated with thePdfName
given is retrieved and resolved to a direct object. If it is aPdfDictionary
, it is cast down and returned as such. Otherwisenull
is returned.- Parameters:
key
- APdfName
- Returns:
- the associated
PdfDictionary
object, ornull
-
getAsArray
Returns aPdfObject
as aPdfArray
, resolving indirect references. The object associated with thePdfName
given is retrieved and resolved to a direct object. If it is aPdfArray
, it is cast down and returned as such. Otherwisenull
is returned.- Parameters:
key
- APdfName
- Returns:
- the associated
PdfArray
object, ornull
-
getAsStream
Returns aPdfObject
as aPdfStream
, resolving indirect references. The object associated with thePdfName
given is retrieved and resolved to a direct object. If it is aPdfStream
, it is cast down and returned as such. Otherwisenull
is returned.- Parameters:
key
- APdfName
- Returns:
- the associated
PdfStream
object, ornull
-
getAsString
Returns aPdfObject
as aPdfString
, resolving indirect references. The object associated with thePdfName
given is retrieved and resolved to a direct object. If it is aPdfString
, it is cast down and returned as such. Otherwisenull
is returned.- Parameters:
key
- APdfName
- Returns:
- the associated
PdfString
object, ornull
-
getAsNumber
Returns aPdfObject
as aPdfNumber
, resolving indirect references. The object associated with thePdfName
given is retrieved and resolved to a direct object. If it is aPdfNumber
, it is cast down and returned as such. Otherwisenull
is returned.- Parameters:
key
- APdfName
- Returns:
- the associated
PdfNumber
object, ornull
-
getAsName
Returns aPdfObject
as aPdfName
, resolving indirect references. The object associated with thePdfName
given is retrieved and resolved to a direct object. If it is aPdfName
, it is cast down and returned as such. Otherwisenull
is returned.- Parameters:
key
- APdfName
- Returns:
- the associated
PdfName
object, ornull
-
getAsBoolean
Returns aPdfObject
as aPdfBoolean
, resolving indirect references. The object associated with thePdfName
given is retrieved and resolved to a direct object. If it is aPdfBoolean
, it is cast down and returned as such. Otherwisenull
is returned.- Parameters:
key
- APdfName
- Returns:
- the associated
PdfBoolean
object, ornull
-
getAsIndirectObject
Returns aPdfObject
as aPdfIndirectReference
. The object associated with thePdfName
given is retrieved If it is aPdfIndirectReference
, it is cast down and returned as such. Otherwisenull
is returned.- Parameters:
key
- APdfName
- Returns:
- the associated
PdfIndirectReference
object, ornull
-