usmanazizgroupdocs
12/22/2015 - 6:58 AM

UpdateXMP.cs

//For complete examples and data files, please go to https://github.com/groupdocsmetadata/GroupDocs_Metadata_NET
// path to the modified file
string filePath = "Images/Jpeg/sample.jpg";

// get xmp wrapper
XmpPacketWrapper xmpWrapper = MetadataUtility.ExtractXmpPackage(filePath);

// if wrapper is null
if (xmpWrapper == null)
{
    // create it
    xmpWrapper = new XmpPacketWrapper();
}

// create package
XmpPackage addingSchema = new XmpPackage("rs", "http://www.metadataworkinggroup.com/schemas/regions/");

// set date property
addingSchema.AddValue("rs:createdDate", DateTime.UtcNow);

// set string property
addingSchema.AddValue("rs:File", "File name");

//initialze unordered xmp array
XmpArray managersArray = new XmpArray(XmpArrayType.UNORDERED);
managersArray.AddItem("Joe Doe");
managersArray.AddItem("Adam White");

// set array property
addingSchema.SetArray("rs:managers", managersArray);

// initialize xmp language alternative
LangAlt availableDays = new LangAlt();
// add first value for 'en-us' language
availableDays.AddLanguage("en-us", "Tue");
// add second value for 'en-us' languge
availableDays.AddLanguage("en-us", "Fri");

// set LangAlt property
addingSchema.SetLangAlt("rs:days", availableDays);

// update xmp wrapper with new schema
xmpWrapper.AddPackage(addingSchema);

// create XmpMetadata with updated wrapper
XmpMetadata xmpMetadata = new XmpMetadata();
xmpMetadata.XmpPacket = xmpWrapper;

// update XMP
MetadataUtility.UpdateMetadata(filePath, xmpMetadata);