---
title: "Edit PDF metadata on iOS | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/ios/customizing-pdf-pages/customizing-document-metadata/"
md_url: "https://www.nutrient.io/guides/ios/customizing-pdf-pages/customizing-document-metadata.md"
last_updated: "2026-06-09T10:38:40.897Z"
description: "Learn how to retrieve and customize PDF metadata using Nutrient's PDFMetadata and XMPMetadata for effective document management."
---

# Edit PDF metadata on iOS

Metadata may be stored in a PDF document in two ways: in a document information dictionary associated with the document, or in a metadata stream containing XMP data. To give you full access to all the PDF metadata, Nutrient comes with [`PDFMetadata`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdfmetadata) and [`XMPMetadata`](https://www.nutrient.io/api/ios/documentation/pspdfkit/xmpmetadata), which allow you to retrieve or modify a document’s metadata.

## PDF metadata

Use [`PDFMetadata`](https://www.nutrient.io/api/ios/documentation/pspdfkit/pdfmetadata) to work with the dictionary-based metadata in a PDF.

All values specified in the PDF Info Dictionary are represented by the following types:

| Swift                            | Objective-C                   |
| -------------------------------- | ----------------------------- |
| `String`                         | `NSString`                    |
| `Int`, `Float`, `Double`, `Bool` | `NSNumber`                    |
| `Date`                           | `NSDate`                      |
| `Array<Any>`                     | `NSArray<id>`                 |
| `Dictionary<String, Any>`        | `NSDictionary<NSString*, id>` |

The `Any` and `id` types above can include any of the types mentioned.

These types can be combined in any way you see fit and will be converted into the proper PDF types.

By default, the dictionary metadata may contain the following info keys:

- `Author`

- `CreationDate`

- `Creator`

- `Keywords`

- `ModDate`

- `Producer`

- `Title`

You can, of course, add any supported key-value dictionary to the metadata.



### Retrieving

To get an entry of the metadata dictionary (e.g. the `Author`), you can use the following code snippet:

### SWIFT

```swift

let document =...
let pdfMetadata = PDFMetadata(document: document)
let author = pdfMetadata?.object(forInfoDictionaryKey:.author)

```

### OBJECTIVE-C

```objc

PSPDFDocument *document =...
PSPDFDocumentPDFMetadata *pdfMetadata = [[PSPDFDocumentPDFMetadata alloc] initWithDocument:document];
NSString *author = [pdfMetadata objectForInfoDictionaryKey:PSPDFMetadataAuthorKey];

```

### Saving

You can customize the document metadata and then save the document, which also saves the modified metadata into the PDF:

### SWIFT

```swift

let pdfMetadata = PDFMetadata(document: document)
pdfMetadata?.setObject("MyValue", forInfoDictionaryKey: PDFMetadata.Key("MyCustomKey"))

try? document.save()

```

### OBJECTIVE-C

```objc

PSPDFDocumentPDFMetadata *pdfMetadata = [[PSPDFDocumentPDFMetadata alloc] initWithDocument:document];

PSPDFMetadataName metadataKey = @"MyKey";
NSArray *metadataValue = @[@"MyValue"];
[pdfMetadata setObject:metadataValue forKeyedSubscript:metadataKey];

[document saveWithOptions:nil error:NULL];

```

## XMP metadata

Use [`XMPMetadata`](https://www.nutrient.io/api/ios/documentation/pspdfkit/xmpmetadata) to work with the metadata stream containing XMP data.

Each key in the XMP metadata stream has to have a namespace set. You can define your own namespace or use one of the already existing ones. Nutrient exposes two constants for common namespaces:

- `PSPDFXMPPDFNamespace`/`PSPDFXMPPDFNamespacePrefix` — [the XMP PDF namespace created by Adobe](https://github.com/adobe/XMP-Toolkit-SDK/blob/main/docs/XMPSpecificationPart2.pdf) §3.1

- `PSPDFXMPDCNamespace`/`PSPDFXMPDCNamespacePrefix` — [the Dublin Core namespace](https://en.wikipedia.org/wiki/Dublin_Core)





When setting a value, you also have to pass along a suggested namespace prefix, as this can’t be generated automatically.

### Retrieving

Use the following code snippet to get an object from the XMP metadata:

### SWIFT

```swift

let xmpMetadata = XMPMetadata(document: document)
let documentFormat = xmpMetadata?.string(forXMPKey: "format", namespace: PSPDFXMPDCNamespace)

```

### OBJECTIVE-C

```objc

PSPDFDocumentXMPMetadata *xmpMetadata = [[PSPDFDocumentXMPMetadata alloc] initWithDocument:document];
NSString *documentFormat = [xmpMetadata stringForXMPKey:@"format" namespace:PSPDFXMPDCNamespace];

```

### Saving

You can also set new metadata and save it to the document:

### SWIFT

```swift

let xmpMetadata = XMPMetadata(document: document)

let metadataKey = "MyKey"
let metadataValue = "MyValue"

xmpMetadata?.setString(metadataValue, forXMPKey: metadataKey, namespace: PSPDFXMPPDFNamespace, suggestedNamespacePrefix: PSPDFXMPPDFNamespacePrefix)

```

### OBJECTIVE-C

```objc

PSPDFDocumentXMPMetadata *xmpMetadata = [[PSPDFDocumentXMPMetadata alloc] initWithDocument:document];

NSString *metadataKey = @"MyKey";
NSString *metadataValue = @"MyValue";

[xmpMetadata setString:metadataValue forXMPKey:metadataKey namespace:PSPDFXMPPDFNamespace suggestedNamespacePrefix:PSPDFXMPPDFNamespacePrefix];
[document saveWithOptions:nil error:NULL];

```
---

## Related pages

- [Change the document title in PDF metadata on iOS](/guides/ios/customizing-the-interface/changing-the-document-title.md)
- [Customize the document information on iOS](/guides/ios/customizing-the-interface/customizing-the-available-document-information.md)

