Set document metadata on save
Leave feedback
On this page
Document can contain some metadata information, such as author, organization, etc. GroupDocs.Comparison allows you to select metadata source when saving output document.
Possible metadata sources are as follows:
- Source document metadata
- Target document metadata
- User-defined metadata
To set output document metadata, follow these steps:
- Instantiate the Comparer object. Specify the source document path or stream.
- Call the Add method. Specify the target document path or stream.
- Instantiate the SaveOptions object. Set the CloneMetadataType property to the appropriate MetadataType variant.
- Call the Compare method. Specify the SaveOptions object as a parameter.
The following code snippets show how to set output document metadata:
using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
// ...
using (Comparer comparer = new Comparer("source.docx"))
{
comparer.Add("target.docx");
comparer.Compare("result.docx", new SaveOptions() { CloneMetadataType = MetadataType.Source });
}
using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
// ...
using (Comparer comparer = new Comparer("source.docx"))
{
comparer.Add("target.docx");
comparer.Compare("result.docx", new SaveOptions() { CloneMetadataType = MetadataType.Target });
}
using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;
// ...
using (Comparer comparer = new Comparer("source.docx"))
{
comparer.Add("target.docx");
SaveOptions saveOptions = new SaveOptions()
{
CloneMetadataType = MetadataType.FileAuthor,
FileAuthorMetadata = new FileAuthorMetadata
{
Author = "Tom",
Company = "GroupDocs",
LastSaveBy = "Jack"
}
};
comparer.Compare("result.docx", saveOptions);
}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.