Add XML namespace in XMP metadata of EPS

To add an XML namespace in the XMP metadata of an EPS file, it is necessary to do several steps:

  1. Create file reader ‘const file_reader = new FileReader();’ and read file ‘file_reader.readAsArrayBuffer(e.target.files[0]);’.
  2. On load event handler call AsposeXMPAddNamespace and pass the file content, its name, result file name, prefix, url, and an array of key-value pairs for the new namespace to it.
  3. The result JSON contains the file name in fileNameResult.
  4. You can download files by using the DownloadFile function: ‘DownloadFile(JSON.fileNameResult, “image/pdf”);’ and display the result ‘document.getElementById(‘output’).textContent = JSON.XMP;’


following code snippet shows how to add an XML namespace in XMP metadata in an EPS file in C++:

 1  var fXMPAddNamespace = function (e) {
 2    const file_reader = new FileReader();
 3    file_reader.onload = (event) => {
 4      const prefix = "tmp";
 5      const url = "http://www.some.org/schema/tmp#";
 6      const input = [
 7        ["tmp:newKey", "NewValue"]
 8      ];
 9      const JSON = AsposeXMPAddNamespace(event.target.result, e.target.files[0].name, e.target.files[0].name + "_out.eps", prefix, url, input);
10      if (JSON.errorCode == 0) {
11          DownloadFile(JSON.fileNameResult, "image/eps");
12      }
13      else 
14        document.getElementById('output').textContent = JSON.errorText;
15    }
16    file_reader.readAsArrayBuffer(e.target.files[0]);
17  }

See adding XMl namespace in XMP metadata in Java and .NET.

You can download examples and data files from GitHub.