Search code examples
c#.netms-wordxceedxceed-datagrid

How to remove the Related People (Author and Modified By) property of Word file using Xceed in C#


I am using the Xceed library to create a word file. Now I want to remove the Related People (Author and Modified By) property of the word document.

Here is my code:

using Xceed.Words.NET;
using Xceed.Document.NET;
using Image = Xceed.Document.NET.Image;
using Paragraph = Xceed.Document.NET.Paragraph;
using Formatting = Xceed.Document.NET.Formatting;
using Font = Xceed.Document.NET.Font;

How can I achieve this ?


Solution

  • Answering my own question, this can be done by adding the AddCoreProperty as below:

    // Load your Document
    var doc = DocX.Load(@"your-docx-file-path");
    // Access Metadata properties
    var props = doc.CoreProperties;
    // Update Metadata
    doc.AddCoreProperty("cp:lastModifiedBy", "");
    doc.AddCoreProperty("dc:creator", "");
    doc.Save();
    

    Set docx properties using library .docx