Class PdfDictionary
- java.lang.Object
-
- com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfObject
-
- com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfDictionary
-
- Direct Known Subclasses:
PdfAcroForm
,PdfAction
,PdfAnnotation
,PdfBorderDictionary
,PdfDocument.PdfCatalog
,PdfDocument.PdfInfo
,PdfFileSpecification
,PdfGState
,PdfLayer
,PdfLayerMembership
,PdfMediaClipData
,PdfOCProperties
,PdfOutline
,PdfPage
,PdfRendition
,PdfResources
,PdfShadingPattern
,PdfSignature
,PdfStream
,PdfStructureElement
,PdfStructureTreeRoot
,PdfTransparencyGroup
,PdfWriter.PdfTrailer
,PRAcroForm
public class PdfDictionary extends PdfObject
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 ofPdfObject
, 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.3' section 4.7 (page 40-41).- See Also:
PdfObject
,PdfName
,BadPdfFormatException
-
-
Field Summary
Fields Modifier and Type Field Description static PdfName
CATALOG
This is a possible type of dictionaryprivate PdfName
dictionaryType
This is the type of this dictionarystatic PdfName
FONT
This is a possible type of dictionaryprotected java.util.HashMap
hashMap
This is the hashmap that contains all the values and keys of the dictionarystatic PdfName
OUTLINES
This is a possible type of dictionarystatic PdfName
PAGE
This is a possible type of dictionarystatic PdfName
PAGES
This is a possible type of dictionary
-
Constructor Summary
Constructors Constructor Description PdfDictionary()
Constructs an emptyPdfDictionary
-object.PdfDictionary(PdfName type)
Constructs aPdfDictionary
-object of a certain type.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description boolean
contains(PdfName key)
PdfObject
get(PdfName key)
Gets aPdfObject
with a certain key from thePdfDictionary
.PdfArray
getAsArray(PdfName key)
Returns aPdfObject
as aPdfArray
, resolving indirect references.PdfBoolean
getAsBoolean(PdfName key)
Returns aPdfObject
as aPdfBoolean
, resolving indirect references.PdfDictionary
getAsDict(PdfName key)
Returns aPdfObject
as aPdfDictionary
, resolving indirect references.PdfIndirectReference
getAsIndirectObject(PdfName key)
Returns aPdfObject
as aPdfIndirectReference
.PdfName
getAsName(PdfName key)
Returns aPdfObject
as aPdfName
, resolving indirect references.PdfNumber
getAsNumber(PdfName key)
Returns aPdfObject
as aPdfNumber
, resolving indirect references.PdfStream
getAsStream(PdfName key)
Returns aPdfObject
as aPdfStream
, resolving indirect references.PdfString
getAsString(PdfName key)
Returns aPdfObject
as aPdfString
, resolving indirect references.PdfObject
getDirectObject(PdfName key)
Returns thePdfObject
associated to the specified key, resolving a possible indirect reference to a direct object.java.util.Set
getKeys()
boolean
isCatalog()
Checks if aDictionary
is of the type CATALOG.boolean
isDictionaryType(PdfName type)
Deprecated.boolean
isFont()
Checks if aDictionary
is of the type FONT.boolean
isOutlineTree()
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
put(PdfName key, PdfObject object)
Adds aPdfObject
and its key to thePdfDictionary
.void
putAll(PdfDictionary dic)
void
putDel(PdfName key, PdfObject object)
Adds aPdfObject
and its key to thePdfDictionary
.void
putEx(PdfName key, PdfObject value)
Adds aPdfObject
and its key to thePdfDictionary
.void
remove(PdfName key)
Removes aPdfObject
and its key from thePdfDictionary
.int
size()
void
toPdf(PdfWriter writer, java.io.OutputStream os)
Returns the PDF representation of thisPdfDictionary
.-
Methods inherited from class com.gitlab.pdftk_java.com.lowagie.text.pdf.PdfObject
canBeInObjStm, getBytes, getIndRef, isArray, isBoolean, isDictionary, isIndirect, isName, isNull, isNumber, isStream, isString, length, setContent, setIndRef, toString, type
-
-
-
-
Field Detail
-
FONT
public static final PdfName FONT
This is a possible type of dictionary
-
OUTLINES
public static final PdfName OUTLINES
This is a possible type of dictionary
-
PAGE
public static final PdfName PAGE
This is a possible type of dictionary
-
PAGES
public static final PdfName PAGES
This is a possible type of dictionary
-
CATALOG
public static final PdfName CATALOG
This is a possible type of dictionary
-
dictionaryType
private PdfName dictionaryType
This is the type of this dictionary
-
hashMap
protected java.util.HashMap hashMap
This is the hashmap that contains all the values and keys of the dictionary
-
-
Constructor Detail
-
PdfDictionary
public PdfDictionary()
Constructs an emptyPdfDictionary
-object.
-
PdfDictionary
public PdfDictionary(PdfName type)
Constructs aPdfDictionary
-object of a certain type.- Parameters:
type
- aPdfName
-
-
Method Detail
-
toPdf
public void toPdf(PdfWriter writer, java.io.OutputStream os) throws java.io.IOException
Returns the PDF representation of thisPdfDictionary
.
-
put
public void put(PdfName key, PdfObject object)
Adds aPdfObject
and its key to thePdfDictionary
.- Parameters:
key
- key of the entry (aPdfName
)value
- value of the entry (aPdfObject
)
-
putEx
public void putEx(PdfName key, PdfObject value)
Adds aPdfObject
and its key to thePdfDictionary
. If the value is null it does nothing.- Parameters:
key
- key of the entry (aPdfName
)value
- value of the entry (aPdfObject
)
-
putAll
public void putAll(PdfDictionary dic)
-
putDel
public void putDel(PdfName key, PdfObject object)
Adds aPdfObject
and its key to thePdfDictionary
. If the value is null the key is deleted.- Parameters:
key
- key of the entry (aPdfName
)value
- value of the entry (aPdfObject
)
-
remove
public void remove(PdfName key)
Removes aPdfObject
and its key from thePdfDictionary
.- Parameters:
key
- key of the entry (aPdfName
)
-
get
public PdfObject get(PdfName key)
Gets aPdfObject
with a certain key from thePdfDictionary
.- Parameters:
key
- key of the entry (aPdfName
)- Returns:
- the previous PdfObject corresponding with the key
-
getDirectObject
public PdfObject getDirectObject(PdfName key)
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
public java.util.Set getKeys()
-
size
public int size()
-
contains
public boolean contains(PdfName key)
-
isDictionaryType
public boolean isDictionaryType(PdfName type)
Deprecated.Checks if aPdfDictionary
is of a certain type.- Parameters:
type
- a type of dictionary- Returns:
true
offalse
-
isFont
public boolean isFont()
Checks if aDictionary
is of the type FONT.- Returns:
true
if it is,false
if it isn't.
-
isPage
public boolean isPage()
Checks if aDictionary
is of the type PAGE.- Returns:
true
if it is,false
if it isn't.
-
isPages
public boolean isPages()
Checks if aDictionary
is of the type PAGES.- Returns:
true
if it is,false
if it isn't.
-
isCatalog
public boolean isCatalog()
Checks if aDictionary
is of the type CATALOG.- Returns:
true
if it is,false
if it isn't.
-
isOutlineTree
public boolean isOutlineTree()
Checks if aDictionary
is of the type OUTLINES.- Returns:
true
if it is,false
if it isn't.
-
merge
public void merge(PdfDictionary other)
-
mergeDifferent
public void mergeDifferent(PdfDictionary other)
-
getAsDict
public PdfDictionary getAsDict(PdfName key)
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
public PdfArray getAsArray(PdfName key)
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
public PdfStream getAsStream(PdfName key)
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
public PdfString getAsString(PdfName key)
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
public PdfNumber getAsNumber(PdfName key)
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
public PdfName getAsName(PdfName key)
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
public PdfBoolean getAsBoolean(PdfName key)
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
public PdfIndirectReference getAsIndirectObject(PdfName key)
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
-
-