<!--
{
  "documentType" : "article",
  "framework" : "CoreGraphics",
  "identifier" : "/documentation/CoreGraphics/cgpdfdictionary",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "CGPDFDictionary"
}
-->

# CGPDFDictionary

A dictionary structure within a PDF document.

## Discussion

Dictionary objects are the main building blocks of a PDF document. A key-value pair within a dictionary is called an entry. In a PDF dictionary, the key must be an array of characters. Within a given dictionary, the keys are unique—that is, no two keys in a single dictionary are equal (as determined by `strcmp`). The value associated with a key can be any kind of PDF object, including another dictionary. Dictionary objects are the main building blocks of a PDF document.

Many functions that retrieve values from a PDF dictionary take the form:

```objc
bool CGPDFDictionaryGet<DataType> (
 CGPDFDictionaryRef dictionary,
 const char *key,
 <DataType>Ref *value
);
```

These functions test whether there is an object associated with the specified key. If there is an object associated with the specified key, they test its data type. If there is no associated object, or if there is but it is not of the expected type, the function returns <doc://com.apple.documentation/documentation/Swift/false>. If there is an object associated with the specified key and it is of the expected type, the function returns <doc://com.apple.documentation/documentation/Swift/true> and the object is passed back in the `value` parameter.

This object is not derived from CFType and therefore there are no functions for retaining and releasing it. CGPDFDictionary objects exist only as constituent parts of a CGPDFDocument object, and they are managed by their container.

## Topics

### Applying a Function to All Entries

[`CGPDFDictionaryApplyFunction`](/documentation/CoreGraphics/CGPDFDictionaryApplyFunction(_:_:_:))

Applies a function to each entry in a dictionary.

### Getting Data from a Dictionary

[`CGPDFDictionaryGetArray`](/documentation/CoreGraphics/CGPDFDictionaryGetArray(_:_:_:))

Returns whether there is a PDF array associated with a specified key in a PDF dictionary and, if so, retrieves that array.

[`CGPDFDictionaryGetBoolean`](/documentation/CoreGraphics/CGPDFDictionaryGetBoolean(_:_:_:))

Returns whether there is a PDF Boolean value associated with a specified key in a PDF dictionary and, if so, retrieves the Boolean value.

[`CGPDFDictionaryGetCount`](/documentation/CoreGraphics/CGPDFDictionaryGetCount(_:))

Returns the number of entries in a PDF dictionary.

[`CGPDFDictionaryGetDictionary`](/documentation/CoreGraphics/CGPDFDictionaryGetDictionary(_:_:_:))

Returns whether there is another PDF dictionary associated with a specified key in a PDF dictionary and, if so, retrieves that dictionary.

[`CGPDFDictionaryGetInteger`](/documentation/CoreGraphics/CGPDFDictionaryGetInteger(_:_:_:))

Returns whether there is a PDF integer associated with a specified key in a PDF dictionary and, if so, retrieves that integer.

[`CGPDFDictionaryGetName`](/documentation/CoreGraphics/CGPDFDictionaryGetName(_:_:_:))

Returns whether an object with a specified key in a PDF dictionary is a PDF name reference (represented as a constant C string) and, if so, retrieves that name.

[`CGPDFDictionaryGetNumber`](/documentation/CoreGraphics/CGPDFDictionaryGetNumber(_:_:_:))

Returns whether there is a PDF number associated with a specified key in a PDF dictionary and, if so, retrieves that number.

[`CGPDFDictionaryGetObject`](/documentation/CoreGraphics/CGPDFDictionaryGetObject(_:_:_:))

Returns whether there is a PDF object associated with a specified key in a PDF dictionary and, if so, retrieves that object.

[`CGPDFDictionaryGetStream`](/documentation/CoreGraphics/CGPDFDictionaryGetStream(_:_:_:))

Returns whether there is a PDF stream associated with a specified key in a PDF dictionary and, if so, retrieves that stream.

[`CGPDFDictionaryGetString`](/documentation/CoreGraphics/CGPDFDictionaryGetString(_:_:_:))

Returns whether there is a PDF string associated with a specified key in a PDF dictionary and, if so, retrieves that string.

### Callbacks

[`CGPDFDictionaryApplierFunction`](/documentation/CoreGraphics/CGPDFDictionaryApplierFunction)

Performs custom processing on a key-value pair from a PDF dictionary, using optional contextual information.

### Data Types

[`CGPDFDictionaryRef`](/documentation/CoreGraphics/CGPDFDictionaryRef)

A type that encapsulates a PDF dictionary.

## See Also

  [Quartz 2D Programming Guide](https://developer.apple.com/library/archive/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/Introduction/Introduction.html#//apple_ref/doc/uid/TP30001066)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)