Set document metadata on save

Usually documents can contain some metadata information, such as author, organization, etc. GroupDocs.Comparison provides an ability to select metadata source when saving resultant document.
Possible metadata sources are:

  • Source document metadata;
  • Target document metadata;
  • User-defined metadata.

The following are the steps to set resultant document metadata.

The following code demonstrates how to set resultant document metadata.

Set metadata from source file

using (Comparer comparer = new Comparer("source.docx"))
{
	comparer.Add("target.docx");
    comparer.Compare("result.docx", new SaveOptions() { CloneMetadataType = MetadataType.Source });
}

Set metadata from target file

using (Comparer comparer = new Comparer("source.docx"))
{
	comparer.Add("target.docx");
    comparer.Compare("result.docx", new SaveOptions() { CloneMetadataType = MetadataType.Target });
}

Set user-defined metadata 

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);
}

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to compare your DOC or DOCX, XLS or XLSX, PPT or PPTX, PDF, EML, EMLX, MSG and other documents with free to use online GroupDocs Comparison App.