GroupDocsGists
10/19/2017 - 11:20 AM

GetIPTCMetadata.cs

// For complete examples and data files, please go to https://github.com/groupdocs-metadata/GroupDocs.Metadata-for-.NET
// initialize JpegFormat
JpegFormat jpegFormat = new JpegFormat(Common.MapSourceFilePath(filePath));

// if file contains iptc metadata
if (jpegFormat.HasIptc)
{
    // get iptc collection
    IptcCollection iptcCollection = jpegFormat.GetIptc();

    // go through array and write property name and formatted value
    foreach (IptcProperty iptcProperty in iptcCollection)
    {
        Console.WriteLine(string.Format("{0}: {1}", iptcProperty.Name, iptcProperty.GetFormattedValue()));
    }

    // initialize IptcDataSetCollection to read well-known properties
    IptcDataSetCollection dsCollection = new IptcDataSetCollection(iptcCollection);

    // try to read Application Record dataset
    if (dsCollection.ApplicationRecord != null)
    {
        // get category
        string category = dsCollection.ApplicationRecord.Category;

        // get headline
        string headline = dsCollection.ApplicationRecord.Headline;
    }

    if (dsCollection.EnvelopeRecord != null)
    {
        // get model version
        int? modelVersion = dsCollection.EnvelopeRecord.ModelVersion;

        // get dataSent property
        DateTime? dataSent = dsCollection.EnvelopeRecord.DataSent;
    }
}