Created
November 27, 2019 08:50
-
-
Save GroupDocsGists/b02f66ab5a9408f72b920cf030ce064a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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