Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save groupdocs-com-kb/2b12133829671beeedcde1652ca97080 to your computer and use it in GitHub Desktop.
Save groupdocs-com-kb/2b12133829671beeedcde1652ca97080 to your computer and use it in GitHub Desktop.
Remove Metadata from DOCM using Java. For more information, please follow link: https://kb.groupdocs.com/metadata/java/remove-metadata-from-docm-using-java/
import com.groupdocs.metadata.Metadata;
import com.groupdocs.metadata.core.FileFormat;
import com.groupdocs.metadata.licensing.License;
import com.groupdocs.metadata.search.FallsIntoCategorySpecification;
import com.groupdocs.metadata.search.WithNameSpecification;
import com.groupdocs.metadata.tagging.Tags;
public class RemoveMetadatafromDOCMUsingJava {
public static void main(String[] args) {
// Set License to avoid the limitations of Metadata library
License license = new License();
license.setLicense("GroupDocs.Metadata.lic");
Metadata metadata = new Metadata("input.docm");
if (metadata.getFileFormat() != FileFormat.Unknown
&& !metadata.getDocumentInfo().isEncrypted()) {
System.out.println();
// Remove all mentions of any people contributed in file creation
// Remove a custom property with the specified name
int affected = metadata.removeProperties(new FallsIntoCategorySpecification(
Tags.getPerson()).or(new WithNameSpecification("CustomProperty")));
System.out.println(String.format("Affected properties: %s", affected));
metadata.save("output.docm");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment