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.

The following code snippet shows how to add properties in XMP metadata of EPS file in C#:

 1// Add simple properties in XMP metadata in EPS document.
 2
 3// Initialize EPS file input stream
 4System.IO.FileStream psStream = new System.IO.FileStream(DataDir + "add_simple_props_input.eps", System.IO.FileMode.Open, System.IO.FileAccess.Read);
 5
 6// Create PsDocument instance from stream
 7PsDocument document = new PsDocument(psStream);
 8
 9string outputFileName = "add_xmp_simple_props_out.eps";
10DateTime now = DateTime.UtcNow;
11
12try
13{
14    // 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)
15    XmpMetadata xmp = document.GetXmpMetadata();
16
17    //Change XMP metadata values
18
19    // Add Integer poperty
20    xmp.Add("xmp:Intg1", new XmpValue(111));
21
22    // Add DateTime poperty
23    xmp.Add("xmp:Date1", new XmpValue(now));
24
25    // Add Double poperty
26    xmp.Add("xmp:Double1", new XmpValue(111.11D));
27
28    // Add String poperty
29    xmp.Add("xmp:String1", new XmpValue("ABC"));
30
31    // Save EPS file with changed XMP metadata
32
33    // Create ouput stream
34    using (System.IO.FileStream outPsStream = new System.IO.FileStream(OutputDir + outputFileName, System.IO.FileMode.Create, System.IO.FileAccess.Write))
35    {
36        // Save EPS file
37        document.Save(outPsStream);
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.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.