Add properties 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 properties 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 properties of 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 properties in XMP metadata of 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_props_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    DateTime now = DateTime.UtcNow;
17
18    // Add Integer poperty
19    xmp.Add("xmp:Intg1", new XmpValue(111));
20
21    // Add DateTime poperty
22    xmp.Add("xmp:Date1", new XmpValue(now));
23
24    // Add Double poperty
25    xmp.Add("xmp:Double1", new XmpValue(111.11D));
26
27    // Add String poperty
28    xmp.Add("xmp:String1", new XmpValue("ABC"));
29
30    // Save EPS file with changed XMP metadata
31
32    // Create ouput stream
33    using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "add_props_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
34    {
35        // Save EPS file
36        document.Save(outPsStream);
37    }
38
39}
40finally
41{
42    psStream.Close();
43}

See adding properties 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.