How to Clean Metadata from PDF in C#

This short tutorial guides on how to clean metadata from PDF in C#. It has the details to set the development environment, a list of steps for writing the application, and a runnable sample code to strip PDF metadata in C#. It will also explain the methods to delete the default and custom metadata based on your requirements.

Steps to Remove Metadata from PDF in C#

  1. Set the environment to use Aspose.PDF for .NET to clean the metadata
  2. Load the source PDF file into the Document object to erase the metadata
  3. Get access to the PDF metadata using the DocumentInfo class
  4. Call the Clear() and ClearCustomData() methods to remove the metadata
  5. Save the resultant output PDF file

These steps describe the process to delete PDF metadata in C#. We initialize the process by loading the source PDF file followed by accessing the metadata of the file using the DocumentInfo class object. Finally, call the Clear() and ClearCustomData() methods to clear the default and custom metadata based on your requirements.

Code to Erase Metadata PDF in C#

This code demonstrates the process of developing a metadata removal tool in C#. For removing the selected metadata you may access the desired property in the DocumentInfo object and set its value to null or empty string according to the data type. You may use the IsPredefinedKey() method to check if a property is custom or not to call the appropriate method.

This quick tutorial has guided us to clean metadata from PDF in C#. If you want to remove the hyperlinks from a PDF, refer to the article on how to remove hyperlink from PDF in C#.

 English