Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Regex pattern = new Regex("author|company", RegexOptions.IgnoreCase);
using (Metadata metadata = new Metadata(@"D:\input.docx"))
{
// This method searches for properties across all metadata packages and works with all supported formats
var properties = metadata.FindProperties(p => pattern.IsMatch(p.Name) || pattern.IsMatch(p.Value.ToString()));
foreach (var property in properties)
{
Console.WriteLine("{0} = {1}", property.Name, property.Value);
}
}
Regex pattern = new Regex("author|company", RegexOptions.IgnoreCase);
// This method works with document formats only
MetadataPropertyCollection properties = SearchFacade.ScanDocument(@"D:\input.docx", pattern);
for (int i = 0; i < properties.Count; i++)
{
Console.WriteLine(properties[i]);
}
var pattern = new Regex("^author|company$", RegexOptions.IgnoreCase);
var replaceValue = new PropertyValue("Aspose");
using (Metadata metadata = new Metadata(@"D:\input.docx"))
{
// This method updates writable properties across all metadata packages and works with all supported formats
metadata.UpdateProperties(p => pattern.IsMatch(p.Name), replaceValue);
metadata.Save(@"D:\output.docx");
}
Regex pattern = new Regex("^author|company$", RegexOptions.IgnoreCase);
string replaceValue = "Aspose";
// This method works with document formats only
SearchFacade.ReplaceInDocument(@"D:\input.docx", pattern, replaceValue, @"D:\output.docx");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.