Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clean All Metadata from Documents and Images
/*
* Clean all the detected metadata properties from Word, Excel,
* PowerPoint, PDF, and other documents using C#
*/
using (Metadata metadata = new Metadata("filePath/document.pdf"))
{
var affected = metadata.Sanitize();
metadata.Save("filePath/output.pdf");
}
/*
* Remove all the detected metadata properties from Word, Excel,
* PowerPoint, PDF, and other documents using Java
*/
Metadata metadata = new Metadata("filePath/document.pdf");
int affected = metadata.sanitize();
metadata.save("filePath/output.pdf"); // Save the output document with no metadata
/*
* Clean or remove all the detected metadata properties from PNG, JPG/JPEG,
* WebP, BMP, GIF, TIFF and other images using C#
*/
using (Metadata metadata = new Metadata("filePath/document.jpg"))
{
var affected = metadata.Sanitize();
metadata.Save("filePath/output.jpg");
}
/*
* Remove all the detected metadata properties from JPEG, PNG,
* WebP, BMP, GIF, TIFF and other images using Java
*/
Metadata metadata = new Metadata("filePath/document.jpg");
int affected = metadata.sanitize();
metadata.save("filePath/output.jpg"); // Save the output image having no metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment