Add array items in XMP metadata of EPS| .NET

You can check the quality of Aspose.Page XMP Metadata working with Metadata web app

In order to add array items in XMP metadata of EPS file it is necessary to do several steps:

  1. Initialize an input stream for input EPS file.
  2. Create an instance of PsDocument from created earlier input stream.
  3. Get an instance of XmpMetadata from the PsDocument. If given EPS file doesn’t contain XMP metadata the new one will be created, filled in with values from PS metadata comments and returned to you.
  4. Now you can add items to array metadata fields.
  5. Initialize an output stream for output EPS file.
  6. Save EPS file with changed XMP metadata.


Following code snippet shows how to add array items in XMP metadata in EPS file in C#:

 1// For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-.NET
 2// The path to the documents directory.
 3string dataDir = RunExamples.GetDataDir_WorkingWithXMPMetadataInEPS();
 4// Initialize EPS file input stream
 5System.IO.FileStream psStream = new System.IO.FileStream(dataDir + "add_array_items_input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
 6// Create PsDocument instance from stream
 7PsDocument document = new PsDocument(psStream);            
 8
 9try
10{
11    // Get XMP metadata. If EPS file doesn't contain XMP metadata we get new one filled with values from PS metadata comments (%%Creator, %%CreateDate, %%Title etc)
12    XmpMetadata xmp = document.GetXmpMetadata();
13
14    //Change XMP metadata values
15
16    // Add one more title. I will be added at the end of array by default.
17    xmp.AddArrayItem("dc:title", new XmpValue("NewTitle"));
18
19    // Add one more creator. It will be added in the array by an index (0).
20    xmp.AddArrayItem("dc:creator", 0, new XmpValue("NewCreator"));
21
22    // Save EPS file with changed XMP metadata
23
24    // Create ouput stream
25    using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "add_array_items_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
26    {
27        // Save EPS file
28        document.Save(outPsStream);
29    }
30
31}
32finally
33{
34    psStream.Close();
35}

See adding array items in XMP metadata in Java and C++.

Evaluate XMP metadata working online on our Metadata application.

You can download examples and data files from GitHub.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.