←Select platform

ReadMetadataItems(string,int) Method

Summary
Reads metadata from the specified file.
Syntax
C#
VB
C++
public IDictionary<string, string> ReadMetadataItems( 
   string fileName, 
   int pageNumber 
) 
Public Overloads Function ReadMetadataItems( _ 
   ByVal fileName As String, _ 
   ByVal pageNumber As Integer _ 
) As IDictionary(Of String,String) 
public: 
IDictionary<String^,String^>^ ReadMetadataItems(  
   String^ fileName, 
   int pageNumber 
)  

Parameters

fileName
A String containing the name of the image file from which the metadata should be read.

pageNumber
1-based index to the page number from which the metadata should be read.

Return Value

Returns a Dictionary. of key, value pairs for the file metadata items.

Remarks

The file referenced by filename must be a file format that supports XMP. For example PNG, PDF, JPEG, TIFF, SVG, DOC, DOCX, XLS, XLSX, PPT and PPTX. The possible values for the metadata keys are:

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
public static void ReadMetadataItemsExample() 
{ 
	// The source file 
	string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "random.dxf"); 
 
	using (var codecs = new RasterCodecs()) 
	{ 
		bool isMetadataItemsSupported; 
 
		using (var fileInfo = codecs.GetInformation(srcFileName, false)) 
		{ 
			Console.WriteLine("Format {0}", (int)fileInfo.Format); 
			//Check if Metadata supported for the specified file format. 
			isMetadataItemsSupported = RasterCodecs.MetadataItemsSupported(fileInfo.Format); 
			Console.WriteLine("isMetadataItemsSupported {0}", isMetadataItemsSupported); 
		} 
 
		if (isMetadataItemsSupported) 
		{ 
			IDictionary<string, string> metadata = null; 
 
			try 
			{ 
				//Read Metadata Items 
				metadata = codecs.ReadMetadataItems(srcFileName, 1); 
			} 
			catch (RasterException ex) 
			{ 
				Console.WriteLine(ex.Message); 
			} 
 
			Console.WriteLine("Items count {0}", metadata.Count); 
			foreach (var item in metadata) 
			{ 
				//Key Ex: RasterCodecs.FileMetadataKeyAuthor; 
				Console.WriteLine("{0}: {1}", item.Key, item.Value); 
			} 
		} 
	} 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 21.0.2023.3.27
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.