Change simple values in XMP EPS metadata |.NET

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

In order to change simple values 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 change values 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 change simple values 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 + "change_simple_values_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
17    // Change ModifyDate value
18    DateTime now = DateTime.UtcNow;
19    xmp["xmp:ModifyDate"] = now;
20
21    // Change Creator value
22    XmpValue value = new XmpValue("NewCreator");
23    xmp.Add("dc:creator", value);
24
25    // Change Title value
26    value = new XmpValue("NewTitle");
27    xmp.Add("dc:title", value);
28
29    // Save EPS file with changed XMP metadata
30
31    // Create ouput stream
32    using (System.IO.FileStream outPsStream = new System.IO.FileStream(dataDir + "change_simple_values_output.eps", System.IO.FileMode.Create, System.IO.FileAccess.Write))
33    {
34        // Save EPS file
35        document.Save(outPsStream);
36    }
37
38}
39finally
40{
41    psStream.Close();
42}

See changing simple values 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.