# PDFDict Class

> Represents an associative collection of data elements within a PDF document.

- Product: Adobe PDF Library 18
- Language: Java
- Version: APDFL18.0.5PlusP2e
- HTML page: https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFDict
- Version index: https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/llms.txt

```java
class PDFDict : PDFObject
```

**Namespace:** `com::datalogics::PDFL`

**Inherits from:** [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

## Description

Represents an associative collection of data elements within a PDF document. All objects in a PDF document are built from a collection of simpler objects that represent fundamental datatypes like numbers, strings and arrays. PDFObject and its subclasses allow direct access and manipulation of these simple objects. Some subclasses represent single data elements, such as PDFInteger, which represents a single integer value. Other subclasses represent a collection of PDFObjects, like PDFArray, an indexed array of data elements.

A PDFDict is a heterogenous collection object that maps other PDFObjects (including other PDFDicts) to PDFName objects.

**Referenced by:** [`Action`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Action.md), [`Annotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Annotation.md), [`Bookmark`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Bookmark.md), [`CircleAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/CircleAnnotation.md), [`Container`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Container.md), [`DeviceNColorSpace`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/DeviceNColorSpace.md), [`Document`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Document.md), [`ExtendedGraphicState`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/ExtendedGraphicState.md), [`Font`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Font.md), [`FreeTextAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/FreeTextAnnotation.md), [`GoToAction`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/GoToAction.md), [`HighlightAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/HighlightAnnotation.md), [`InkAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/InkAnnotation.md), [`LaunchAction`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LaunchAction.md), [`LineAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LineAnnotation.md), [`LinkAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LinkAnnotation.md), [`NameTree`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/NameTree.md), [`NumberTree`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/NumberTree.md), [`OptionalContentConfig`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/OptionalContentConfig.md), [`OptionalContentGroup`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/OptionalContentGroup.md), [`PDFStream`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFStream.md), [`Page`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Page.md), [`PolyLineAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PolyLineAnnotation.md), [`PolygonAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PolygonAnnotation.md), [`Redaction`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Redaction.md), [`RemoteGoToAction`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/RemoteGoToAction.md), [`SquareAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/SquareAnnotation.md), [`TextMarkupAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/TextMarkupAnnotation.md), [`URIAction`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/URIAction.md), [`UnderlineAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/UnderlineAnnotation.md)

**Uses types:** [`Document`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Document.md), [`PDFName`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFName.md), [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md), [`PDFObjectEnumProc`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObjectEnumProc.md)

## Constructors

### PDFDict

```java
com.datalogics.PDFL.PDFDict.PDFDict(Document doc, boolean indirect)
```

*constructor*

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Document.md)): Document object containing this PDFDict
- `indirect` (`boolean`): flag marking this as an indirect PDFObject

General constructor

### PDFDict

```java
com.datalogics.PDFL.PDFDict.PDFDict(PDFObject docFromObj, boolean indirect)
```

*constructor*

**Parameters**

- `docFromObj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)): The new PDFArray will be created in the same document as this object.
- `indirect` (`boolean`): flag marking this as an indirect PDFObject

General constructor

## Methods

### clone

```java
PDFObject com.datalogics.PDFL.PDFObject.clone()
```

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object.

Makes a new copy of this PDFObject in memory, in the same document and using same direct/indirect setting as this PDFObject.

### clone

```java
PDFObject com.datalogics.PDFL.PDFObject.clone(Document doc)
```

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Document.md)): The target document in which to create the copy.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object in the specified document.

Makes a new copy of this PDFObject in memory, in the supplied document, using the same direct/indirect setting as this PDFObject.

### clone

```java
PDFObject com.datalogics.PDFL.PDFObject.clone(Document doc, boolean indirect)
```

**Parameters**

- `doc` ([`Document`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Document.md)): The target document in which to create the copy.
- `indirect` (`boolean`): If true, the copy will be an indirect object; if false, it will be direct.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object in the specified document.

Makes a new copy of this PDFObject in memory, in the supplied document, using supplied direct/indirect setting.

### clone

```java
PDFObject com.datalogics.PDFL.PDFObject.clone(PDFObject obj)
```

**Parameters**

- `obj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)): The reference object whose document will be used for the copy.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object in the same document as obj.

Makes a new copy of this PDFObject in memory, in the same document as another object, using the same direct/indirect setting as this PDFObject.

### clone

```java
PDFObject com.datalogics.PDFL.PDFObject.clone(PDFObject obj, boolean indirect)
```

**Parameters**

- `obj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)): The reference object whose document will be used for the copy.
- `indirect` (`boolean`): If true, the copy will be an indirect object; if false, it will be direct.

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

A new PDFObject that is a copy of this object in the same document as obj.

Makes a new copy of this PDFObject in memory, in the same document as another object, using supplied direct/indirect setting.

### compareTo

```java
PDFObjectComparison com.datalogics.PDFL.PDFObject.compareTo(PDFObject rhs)
```

**Parameters**

- `rhs` ([`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)): the other PDFObject to compare.

**Returns:** `PDFObjectComparison`

A PDFObjectComparison value that relates this object to the rhs object

Compares this object to another object. The result is useful for ordering or sorting PDFObjects. No other significance should be attached to the result. In particular, an unequal result indicates nothing about the type of either object.

The result is valid only within a single instance of the document.

### contains

```java
boolean com.datalogics.PDFL.PDFDict.contains(PDFName key)
```

**Parameters**

- `key` ([`PDFName`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFName.md)): A PDFName for the key

**Returns:** `boolean`

true if the given key exists

Tests whether the given key exists in the dictionary

### contains

```java
boolean com.datalogics.PDFL.PDFDict.contains(String key)
```

**Parameters**

- `key` (`String`): A string representing the name for the key

**Returns:** `boolean`

true if the given key exists

Tests whether the given key exists in the dictionary

### delete

```java
synchronized void com.datalogics.PDFL.PDFDict.delete(Boolean disposing)
```

*protected*

**Parameters**

- `disposing` (`Boolean`)

**Returns:** `synchronized void`

### delete

```java
synchronized void com.datalogics.PDFL.PDFDict.delete()
```

**Returns:** `synchronized void`

### destroy

```java
void com.datalogics.PDFL.PDFObject.destroy()
```

**Returns:** `void`

Destroys this object.

This method does nothing if this object is a direct scalar object.

If a composite object (an array, dictionary or stream) is destroyed:
All the direct objects in it are automatically destroyed.

The indirect objects in it are not destroyed.

### enumPDFObjects

```java
boolean com.datalogics.PDFL.PDFObject.enumPDFObjects(PDFObjectEnumProc enumProc)
```

**Parameters**

- `enumProc` ([`PDFObjectEnumProc`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObjectEnumProc.md)): A user-supplied callback to call for each element of the object. of obj. Neither proc nor any routine called by proc may modify the object. Doing so can produce undefined results or errors. For example, if the object is an array, enumProc must not call Remove(); if the object is a dictionary, enumProc must not call Put().

**Returns:** `boolean`

Returns true if every call to enumProc returned true. As soon as any call to enumProc returns false, the enumeration stops and EnumPDFObject() returns false.

Enumerates the elements of a PDFObject by calling a user-supplied procedure for each component of the object.
For scalars or strings, the proc is not called, and CosObjEnum() returns true.

For dictionaries, proc is called for each key-value pair. The order in which the key-value pairs are enumerated is undefined.

For arrays, proc is called with each element as the first paramater to proc, and the NULL object as the second parameter. Array elements are enumerated in ascending order of index.

For streams, proc is called once, with the stream's dictionary as the first parameter to the proc and the NULL object as the second parameter.

### equals

```java
boolean com.datalogics.PDFL.PDFObject.equals(Object rhs)
```

**Parameters**

- `rhs` (`Object`)

**Returns:** `boolean`

### finalize

```java
void com.datalogics.PDFL.PDFDict.finalize()
```

*protected*

**Returns:** `void`

### get

```java
PDFObject com.datalogics.PDFL.PDFDict.get(PDFName key)
```

**Parameters**

- `key` ([`PDFName`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFName.md)): A PDFName for the key

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

A PDFObject matching the key

Returns the object matching the given key.

### get

```java
PDFObject com.datalogics.PDFL.PDFDict.get(String key)
```

**Parameters**

- `key` (`String`): A string representing the name for the key

**Returns:** [`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

A PDFObject matching the key

Returns the object matching the given key string.

### getDocument

```java
Document com.datalogics.PDFL.PDFObject.getDocument()
```

**Returns:** [`Document`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Document.md)

the Document in which the object resides.

The Document of which this object is a member. Returns null if the Document is not known by PDFL, or if it is a temporary document.

If the Document is not null, then it shares the same internal data with other Document objects that refer to the same file. Document objects returned this way do not contribute to the internal count that keeps the Document open, and will become invalid if the main reference to the document is disposed.

### getGeneration

```java
int com.datalogics.PDFL.PDFObject.getGeneration()
```

**Returns:** `int`

The generation number of this indirect object.

The generation number for this object. Only indirect objects have a generation number.

### getID

```java
int com.datalogics.PDFL.PDFObject.getID()
```

**Returns:** `int`

The ID number of this indirect object.

The ID number for this object. Only indirect objects have an ID number.

### getIndirect

```java
boolean com.datalogics.PDFL.PDFObject.getIndirect()
```

**Returns:** `boolean`

true if this object is indirect, false if it is direct.

Indicates if this object is indirect or direct.

### getKeys

```java
java.util.List< PDFObject > com.datalogics.PDFL.PDFDict.getKeys()
```

**Returns:** [`java.util.List< PDFObject >`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)

a list of all the keys

Get a list of all keys in the dictionary

### getPDFHashValue

```java
int com.datalogics.PDFL.PDFObject.getPDFHashValue()
```

**Returns:** `int`

The 32-bit hash value for this object.

The 32-bit hash value for this object. The hash value is used internally to quickly access the object, and is not generally useful for PDFObject users. Note that two PDFObjects with equal hash values are not necessarily equal; use Equals() to check for equality.

### getXMPMetadata

```java
String com.datalogics.PDFL.PDFDict.getXMPMetadata()
```

**Returns:** `String`

The XMP metadata associated with this dictionary.

NULL if there is no such data.

Note: PDFL will not attempt to verify that obj is one of the objects specified to allow XMP metadata by the PDF reference.

### put

```java
void com.datalogics.PDFL.PDFDict.put(PDFName key, PDFObject obj)
```

**Parameters**

- `key` ([`PDFName`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFName.md)): A PDFName for the key
- `obj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)): A PDFObject to add to the dictionary

**Returns:** `void`

Puts an object with the matching key into the dictionary, adding the entry if the key is not already present.

### put

```java
void com.datalogics.PDFL.PDFDict.put(String key, PDFObject obj)
```

**Parameters**

- `key` (`String`): A string representing the name for the key
- `obj` ([`PDFObject`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFObject.md)): A PDFObject to add to the dictionary

**Returns:** `void`

Puts an object with the matching key string into the dictionary, adding the entry if the key is not already present.

### remove

```java
void com.datalogics.PDFL.PDFDict.remove(PDFName key)
```

**Parameters**

- `key` ([`PDFName`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PDFName.md)): A PDFName for the key

**Returns:** `void`

Removes a key/object pair from the dictionary.

### remove

```java
void com.datalogics.PDFL.PDFDict.remove(String key)
```

**Parameters**

- `key` (`String`): A string representing the name for the key

**Returns:** `void`

Removes a key/object pair from the dictionary.

### setXMPMetadata

```java
void com.datalogics.PDFL.PDFDict.setXMPMetadata(String metadata)
```

**Parameters**

- `metadata` (`String`)

**Returns:** `void`

The XMP metadata associated with this dictionary.

NULL if there is no such data.

Note: PDFL will not attempt to verify that obj is one of the objects that is specified in the PDF reference to allow XMP metadata.

### toString

```java
String com.datalogics.PDFL.PDFDict.toString()
```

**Returns:** `String`

A string describing this PDFDict and its properties.

Returns a string representation of this PDFDict.
