How to Remove Metadata from Word Document using C#

This brief tutorial provides instructions on how to remove metadata from Word document using C#. It has details and resources to set the development environment, a list of programming steps, and a runnable sample code for removing metadata from Word using C#. You will get information on clearing all as well as selected properties from the custom and built-in properties collection.

Steps to Clear Metadata from Word Document using C#

  1. Set the environment to use Aspose.Words for .NET to remove metadata
  2. Load the Word Document having custom and built-in properties
  3. Access the custom properties of the loaded document
  4. Call the Clear() method to remove the custom properties completely
  5. Access the built-in properties of the loaded document
  6. Call the Clear() method of the BuiltInDocumentProperties class to clean the values only
  7. Save the resultant file after removing the metadata

These steps present a concise summary of the process on remove all of the document properties and personal information using C#. The process is started by loading the Word file followed by accessing the collection of the custom properties and calling the Clear() method to remove all the properties. In the next steps, the built-in properties collection is accessed followed by calling the Clear() method to delete the values only.

Code to Remove All Document Properties and Personal Information using C#

This code snippet exhibits the process to clean metadata from Word document using C#. You may use the Remove() method of the CustomDocumentProperties and BuiltInDocumentProperties class by providing the property name to delete the values of the particular properties. Similarly, the RemoveAt() method is available to use the property index for removal.

This article has guided us on how to remove all document properties and personal information using C#. If you are keen on developing an application to remove all the page breaks, refer to the article on how to remove all page breaks in Word using C#.

 English