In this concise tutorial you’ll discover how to clean metadata from PDF in C#, with full setup instructions for your development environment, a step‑by‑step walkthrough for building the application, and ready‑to‑run example code to strip PDF metadata in C#. You’ll also learn proven techniques for removing both default and custom metadata to meet any requirement.
Steps to Remove Metadata from PDF in C#
- Set the environment to use Conholdate.Total for .NET to clean the metadata
- Load the source PDF file into the Document object to erase the metadata
- Get access to the PDF metadata using the DocumentInfo class
- Call the Clear() and ClearCustomData() methods to remove the metadata
- Save the resultant output PDF file
This procedure outlines how to delete PDF metadata in C#. Begin by opening the source PDF document, then access its metadata through the DocumentInfo class object. To remove the metadata, use the Clear() method for default metadata and the ClearCustomData() method for any custom metadata, depending on your specific needs.
Code to Erase Metadata PDF in C#
With this sample you now have a fully functional metadata‑removal tool in C#. Simply locate the desired entry in the DocumentInfo object and set it to null or an empty string—whichever matches the property’s type. By calling IsPredefinedKey() you can determine if a key is custom and apply the appropriate removal technique.
This brief guide has shown you how to clean metadata from PDF in C#. If you also need to strip out watermark annotations, check out our detailed walkthrough on how to remove watermark annotation from PDF in C#.