Remove all recognized metadata properties from a file
Sometimes you just need to remove all metadata properties without applying any filters. The best way to do this is the sanitize method.
This example demonstrates how to remove all detected metadata packages/properties.
Load a file to clean
Call the sanitize method
Check the actual number of removed packages/properties
Save the changes
fromgroupdocs.metadataimportMetadatadefclean_metadata():# Open the file to cleanwithMetadata("input.pdf")asmetadata:# sanitize() removes every detected metadata property in one callaffected=metadata.sanitize()print(f"Properties removed: {affected}")# Write the cleaned document to a new filemetadata.save("output.pdf")if__name__=="__main__":clean_metadata()
input.pdf is the sample file used in this example. Click here to download it.