MetadataRemoveProperties Method
Removes metadata properties satisfying the specified predicate.

Namespace: GroupDocs.Metadata
Assembly: GroupDocs.Metadata (in GroupDocs.Metadata.dll) Version: 20.9
Syntax
public int RemoveProperties(
	Func<MetadataProperty, bool> predicate
)

Parameters

predicate
Type: GroupDocs.Metadata.CommonFuncMetadataProperty, Boolean
A function to test each metadata property for a condition.

Return Value

Type: Int32
The number of affected properties.
Remarks
Learn more
Examples
This example demonstrates how to remove specific metadata properties using various criteria.
C#
using (Metadata metadata = new Metadata(Constants.InputDocx))
{
    // Remove all the properties satisfying the predicate:
    // property contains the name of the document author OR
    // it refers to the last editor OR
    // the property value is a string that contains the substring "John" (to remove any mentions of John from the detected metadata)
    var affected = metadata.RemoveProperties(
            p => p.Tags.Contains(Tags.Person.Creator) ||
            p.Tags.Contains(Tags.Person.Editor) ||
            p.Value.Type == MetadataPropertyType.String && p.Value.ToString().Contains("John"));

    Console.WriteLine("Properties removed: {0}", affected);

    metadata.Save(Constants.OutputDocx);
}
See Also