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 the metadata information for PDF documents programmatically on the cloud. In this article, you will learn how to edit the Metadata of PDF files using a REST API in C#.

The following topics shall be covered in this article:

Document Metadata Manipulation REST API and .NET SDK

groupdocs_metadata-for-cloud

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:

Install GroupDocs.Metadata Cloud via NuGet Package Manager

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 Metadata of PDF Files using REST API in C#

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 update the metadata of a PDF file 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:

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

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:

Try Online

Please try the following free online PDF Metadata manipulation tool, which is developed using the above API.

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

Conclusion

In this article, you have learned how to edit the Metadata of PDF documents on the cloud. 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 learn even more about GroupDocs.Metadata Manipulation Cloud API using the documentation. 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