DynaPDF.SetMetadata
-------------------

The function sets or replaces the XMP metadata stream of a specific object.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [5.2](newinversion52.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.SetMetadata"; PDF; ObjType; Handle; XMP ) 

**MBS**( **"DynaPDF.SetMetadata";** /\* The function sets or replaces the XMP metadata stream of a specific object. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$ObjType**; /\* The object type. Can be Catalog, Font, Image, Page or Template.e.g. "Catalog" \*/   
**$Handle**; /\* Object handle or -1 for the catalog object.e.g. -1 \*/   
**$XMP**) /\* The XMP metadata as text. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| ObjType | The object type. Can be Catalog, Font, Image, Page or Template. | "Catalog" |
| Handle | Object handle or -1 for the catalog object. | -1 |
| XMP | The XMP metadata as text. |  |

### Result

Returns OK or error.

### Description

The function sets or replaces the XMP metadata stream of a specific object.   
The function deletes the XMP stream if no buffer will be provided.   
If the global XMP stream of the Catalog object should be replaced then proceed as follows:   
- Set the wished output PDF version with [DynaPDF.SetPDFVersion](DynaPDFSetPDFVersion.md).
- Get a preview of the XMP stream with [DynaPDF.GetMetadata](DynaPDFGetMetadata.md).
- Modify the returned stream as needed and save it with DynaPDF.SetMetadata, finished!

 The above steps make sure that the XMP metadata and document info contain the same values. This is especially important for PDF standards like PDF/A or PDF/X. DynaPDF makes sure that the creation and modification date will not be changed when closing the file.   
See also [SetMetadata](https://www.monkeybreadsoftware.com/DynaPDF-Manual/SetMetadata.shtml) function in DynaPDF manual.

### Examples

Read, change and write XMP metadata:

 Set Variable \[ $pdf ; Value: MBS ("[DynaPDF.New](DynaPDFNew.md)") \]   
\# Load PDF from container   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)"; $pdf ; Merge PDFs::InputPDF ) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)"; $pdf ; 1) \]   
\#   
\# get current XMP   
Set Variable \[ $xmp ; Value: MBS ("[DynaPDF.GetMetadata](DynaPDFGetMetadata.md)"; $pdf ; "catalog"; -1) \]   
\#   
\# delete XMP metadata   
// Set Variable \[ $r ; Value: MBS ("DynaPDF.SetMetaData"; $pdf ; "") \]   
\#   
\# or write new XMP metadata   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetMetaData"; $pdf ; "catalog"; -1; $XMP ) \]   
\#   
\# save   
Set Field \[ Merge PDFs::FinalPDF ; MBS ("[DynaPDF.Save](DynaPDFSave.md)"; $pdf ; "Merged.pdf") \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.Release](DynaPDFRelease.md)"; $pdf ) \]  
Clear metadata for catalog:

 Set Variable \[ $r ; Value: MBS ("DynaPDF.SetMetaData"; $pdf ; "catalog"; -1; "") \]  
Set new metadata for catalog:

 Set Variable \[ $r ; Value: MBS ("DynaPDF.SetMetaData"; $pdf ; "catalog"; -1; $XMP\_neu ) \]  
### See also

- [DynaPDF.GetInMetadata](DynaPDFGetInMetadata.md)
- [DynaPDF.GetMetadata](DynaPDFGetMetadata.md)
- [DynaPDF.ImportPDFFile](DynaPDFImportPDFFile.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.Save](DynaPDFSave.md)
- [DynaPDF.SetLeading](DynaPDFSetLeading.md)
- [DynaPDF.SetPDFVersion](DynaPDFSetPDFVersion.md)

### Blog Entries

- [MBS FileMaker Plugin, version 5.2pr9](https://www.mbsplugins.de/archive/2015-08-01/MBS_FileMaker_Plugin_version_5/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 29th July 2015 , last changed 24th February 2026

  
[DynaPDF.SetMetaConvFlags](DynaPDFSetMetaConvFlags.md) - [DynaPDF.SetMiterLimit](DynaPDFSetMiterLimit.md)

[HTML Version](DynaPDFSetMetadata.shtml)