GroupDocsGists
10/19/2017 - 11:35 AM

UpdateXMP.vb

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

' get xmp wrapper
Dim xmpWrapper As XmpPacketWrapper = MetadataUtility.ExtractXmpPackage(filePath)

' if wrapper is null
If xmpWrapper Is Nothing Then
    ' create it
    xmpWrapper = New XmpPacketWrapper()
End If

' create package
Dim addingSchema As 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
Dim managersArray As New XmpArray(XmpArrayType.UNORDERED)
managersArray.AddItem("Joe Doe")
managersArray.AddItem("Adam White")

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

' initialize xmp language alternative
Dim availableDays As 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
Dim xmpMetadata As New XMPMetadata()
xmpMetadata.XmpPacket = xmpWrapper

' update XMP