Last active
May 24, 2024 18:26
Remove Metadata from DOCM using Java. For more information, please follow link: https://kb.groupdocs.com/metadata/java/remove-metadata-from-docm-using-java/
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
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