Get XMP Metadata of PDF File
In order to get XMP metadata from a PDF file, you need to create PdfXmpMetadata object and bind the PDF file using BindPdf method. You can pass specific XMP metadata properties to the PdfXmpMetadata object to get their values. The following code snippet shows you how to get XMP metadata from a PDF file.
.NET Core 3.1
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
public static void GetXmpMetadata ()
{
// The path to the documents directory
string dataDir = RunExamples . GetDataDir_AsposePdfFacades_WorkingDocuments ();
// Create PdfXmpMetadata object
using ( var xmpMetaData = new Aspose . Pdf . Facades . PdfXmpMetadata ())
{
// Bind pdf file to the object
xmpMetaData . BindPdf ( dataDir + "GetXMPMetadata.pdf" );
// Get XMP Meta Data properties
Console . WriteLine ( ": {0}" , xmpMetaData [ Aspose . Pdf . Facades . DefaultMetadataProperties . CreateDate ]. ToString ());
Console . WriteLine ( ": {0}" , xmpMetaData [ Aspose . Pdf . Facades . DefaultMetadataProperties . MetadataDate ]. ToString ());
Console . WriteLine ( ": {0}" , xmpMetaData [ Aspose . Pdf . Facades . DefaultMetadataProperties . CreatorTool ]. ToString ());
Console . WriteLine ( ": {0}" , xmpMetaData [ "customNamespace:UserPropertyName" ]. ToString ());
Console . ReadLine ();
}
}
.NET 8
// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
public static void GetXmpMetadata ()
{
// The path to the documents directory
string dataDir = RunExamples . GetDataDir_AsposePdfFacades_WorkingDocuments ();
// Create PdfXmpMetadata object
using var xmpMetaData = new Aspose . Pdf . Facades . PdfXmpMetadata ();
// Bind pdf file to the object
xmpMetaData . BindPdf ( dataDir + "GetXMPMetadata.pdf" );
// Get XMP Meta Data properties
Console . WriteLine ( ": {0}" , xmpMetaData [ Aspose . Pdf . Facades . DefaultMetadataProperties . CreateDate ]. ToString ());
Console . WriteLine ( ": {0}" , xmpMetaData [ Aspose . Pdf . Facades . DefaultMetadataProperties . MetadataDate ]. ToString ());
Console . WriteLine ( ": {0}" , xmpMetaData [ Aspose . Pdf . Facades . DefaultMetadataProperties . CreatorTool ]. ToString ());
Console . WriteLine ( ": {0}" , xmpMetaData [ "customNamespace:UserPropertyName" ]. ToString ());
Console . ReadLine ();
}