The document metadata is a piece of information about the document such as author, editing time, etc. stored inside a document. As a C# developer, you can easily edit PDF metadata in C# programmatically. In this article, you will learn how to build a PDF metadata editor in a .NET application.

The following topics shall be covered in this article:

PDF Metadata Editor - API Installation

Edit PDF Metadata in C# - PDF Metadata Editor

For editing metadata of a PDF document, I will be using the .NET SDK of GroupDocs.Metadata Cloud API. It allows you to add, edit, retrieve and remove metadata from almost all industry-standard file formats. You can perform such operations on PDF, Microsoft Word, Excel spreadsheets, PowerPoint presentations, Outlook emails, Visio, OneNote, Project, audio, video, AutoCAD, archive, JPEG, BMP, PNG, and TIFF. It also provides Java SDK as its document metadata manipulation family members for the Cloud API.

You can install GroupDocs.Metadata Cloud SDK for .NET to your Visual Studio project from the NuGet Package manager as shown below:

PDF metadata editor

Install GroupDocs.Metadata Cloud via NuGet Package Manager

You may also install the NuGet Package using the following command in the Package Manager console:

Install-Package GroupDocs.Metadata-Cloud

Please get your Client ID and Client Secret from the dashboard before you start following the steps and available code examples. Once you have your client ID and Secret, add in the code as shown below:

Edit PDF Metadata in C# Programmatically

You can set metadata of PDF documents by following the simple steps given below:

Upload the Document

Firstly, upload the PDF file to the Cloud using the code sample given below:

As a result, the uploaded PDF file (input.pdf) will be available in the files section of your dashboard on the cloud.

Update Metadata of PDF Files using C#

You can edit PDF metadata programmatically by following the steps given below.

  • Create an instance of MetadataApi
  • Set the PDF file path in the FileInfo model
  • Define SetOptions
  • Provide NewValue and Type for SetPropert
  • Define SearchCriteria, provide NameOptions for which to update the value
  • Create SetRequest with SetOptions
  • Get results by calling the MetadataApi.Set() method

The following code sample shows how to set the metadata by property name of a PDF document using a REST API.

Edit Metadata of PDF Documents using REST API in C#

Set Metadata by Property Name

The following code snippet shows how to match the exact property name by setting the ExactPhrase property to True:

Edit Metadata by matching exact property name in PDF Documents using REST API in C#

Set Metadata by Matching Exact Property Name

The following code snippet shows how to define search criteria using Regular expressions to provide the MatchOptions:

online metadata editor

Set Metadata by Matching Property Name with Regular Expression

The following code snippet shows how to update the metadata by providing the property value:

Edit Metadata by matching property value in PDF Documents using REST API in C#

Set Metadata by Matching Property Value

Download the Updated File

The above code samples will save the updated PDF file on the cloud and can be downloaded using the following code sample:

Online Metadata Editor

Please try the following free free Metadata editor, which is developed using the above API.

https://products.groupdocs.app/metadata/pdf

Conclusion

In this article, you have learned how to edit PDF metadata in C#. This article also explained how to programmatically upload a PDF file on the cloud and then download the updated file from the cloud. You can built your own PDF metadata editor using GroupDocs.Metadata Manipulation Cloud API. Please visit the documentation to learn further. We also provide an API Reference section that lets you visualize and interact with our APIs directly through the browser. In case of any ambiguity, please feel free to contact us on the forum.

See Also