Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active March 3, 2022 18:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/9aa3d162544a32eeff377b6caa6fdf4a to your computer and use it in GitHub Desktop.
Save GroupDocsGists/9aa3d162544a32eeff377b6caa6fdf4a to your computer and use it in GitHub Desktop.
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