Table of Contents

Method SyncMetadata



Synchronizes values in XMP Metadata and Document Info.

public void SyncMetadata(bool preferXmp)


preferXmp bool

Whether to treat XMP metadata as the primary source of the information.


This method updates both XMP metadata and Document Info values. The goal is to have both as close to having the same values as possible.

This method adds XMP metadata to the document if there are no XMP metadata before the call.

You can skip metadata synchronization if there are no XMP metadata to embed when saving the document. You can check whether XMP metadata should be embedded when saving the document using the ShouldBeEmbedded() method.

This method checks two or more corresponding properties from PdfInfo and XmpMetadata, takes the first non-null and not empty value, and then applies the value to all the corresponding properties.

When the preferXmp is true, the method starts checking from XMP metadata. Therefore, when all corresponding Document Info and XMP Metadata properties contain non-null and not empty values, the value from XMP will be applied to all the properties. When the preferXmp is false, the method starts checking from Document Info.

Here are the corresponding properties:

This method also updates the following properties with the synced values: