
Metadata acts as a digital business card for a document, containing properties such as title, author, subject, and keywords. Extensible Metadata Platform (XMP) is an XML‑based format that stores metadata as key/value pairs. Using C#, you can programmatically add or edit both document information and XMP metadata in a PDF. This article shows how to edit the metadata of PDF files using C#.
The following topics are covered:
- C# API to Edit Metadata of PDF Files
- Edit Metadata of a PDF File
- Get Metadata of a PDF File
- Get XMP Metadata from a PDF File
- Set XMP Metadata in a PDF File
- Customize XMP Metadata Namespace in a PDF File
C# API to Edit Metadata of PDF Files
To edit PDF metadata, we use the Aspose.PDF for .NET API. It enables generation, modification, conversion, rendering, security, and printing of supported documents without Adobe Acrobat. Download the DLL or install via NuGet.
PM> Install-Package Aspose.Pdf
Edit Metadata of a PDF File in C#
The DocumentInfo class represents PDF meta‑information. Follow these steps:
- Load a PDF with the Document class.
- Create a DocumentInfo instance using the document object.
- Set properties such as Author, CreationDate, Keywords, Subject, and Title.
- Save the PDF with Document.Save() and specify the output path.
The code sample demonstrates how to edit metadata of a PDF file using C#.

Edit Metadata of a PDF File in C#.
Get Metadata of a PDF File using C#
Read basic PDF information with these steps:
- Load the PDF using the Document class.
- Create a DocumentInfo instance from the document.
- Access and display the metadata properties.
The sample shows how to get metadata of a PDF file using C#.
Author: Aspose
Creation Date: 2/9/2022 9:47:00 AM
Keywords: Aspose.Pdf, DOM, API
Modify Date: 2/9/2022 9:47:00 AM
Subject: PDF Information
Title: Setting PDF Document Information
Get XMP Metadata of a PDF File using C#
Retrieve XMP metadata with these steps:
The example shows how to get XMP metadata of a PDF file using C#.
xmp:CreateDate: 2022-02-09T08:57:00.7+05:00
xmp:Nickname: Nickname
xmp:CustomProperty: Custom Value
Set XMP Metadata in a PDF File using C#
Set XMP metadata via the Metadata property of the Document class:
- Load the PDF with the Document class.
- Assign values to the Metadata property.
- Save the PDF using Document.Save().
The code sample illustrates how to set XMP metadata of a PDF file using C#.
Customize XMP Metadata Namespace in a PDF File
You can define a custom namespace URI instead of the default XMP specifications. Use the RegisterNamespaceUri method in the Metadata class:
- Load the PDF with the Document class.
- Call RegisterNamespaceUri with a prefix and namespace URI.
- Set metadata values via the Metadata property.
- Save the PDF using Document.Save().
The sample demonstrates how to set a custom metadata namespace in a PDF file using C#.
Read the custom XMP metadata properties with the same approach:
myown:ModifyDate: 2022-02-09T10:38:26.8+05:00
myown:CreateDate: 2022-02-09T10:38:26.8+05:00
myown:DeveloperName: Developer Name
myown:MyProperty: My Custom Value
Get a Free API License
Request a free temporary license to use the API without evaluation limits.
Conclusion
In this article you learned how to:
- add or edit basic PDF information using C#;
- set and retrieve XMP metadata in a PDF file;
- define a custom metadata namespace with a prefix.
Explore more about Aspose.PDF for .NET in the documentation. For questions, visit the forum.