Add array items in XMP metadata of EPS| JavaScript

To add array items in XMP metadata of 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 AsposeXMPAddArrayItem and pass the file content, his name, and the result file name to it.
  3. If the EPS file doesn’t contain XMP metadata, we get a new one filled with values from PS metadata comments (%%Creator, %%CreateDate, %%Title, etc).
  4. The result JSON contains the file name in fileNameResult and gets metadata in the XMP element.
  5. You can download files by using the DownloadFile function: ‘DownloadFile(JSON.fileNameResult, “image/pdf”);’ and display the result ‘document.getElementById(‘output’).textContent = JSON.XMP;’


The following code snippet shows how to add array items in XMP metadata in an EPS file in JavaScript:

 1  var fXMPAddArrayItem = function (e) {
 2    const file_reader = new FileReader();
 3    file_reader.onload = (event) => {
 4      const input = [
 5        ["dc:title", "NewTitle"],
 6        ["dc:creator", "NewCreator"]
 7      ];
 8      const JSON = XMPAddArrayItem(event.target.result, e.target.files[0].name, e.target.files[0].name + "_out.eps", input);
 9      if (JSON.errorCode == 0) {
10          DownloadFile(JSON.fileNameResult, "image/eps");
11      }
12      else 
13        document.getElementById('output').textContent = JSON.errorText;
14    }
15    file_reader.readAsArrayBuffer(e.target.files[0]);
16  }

See adding array items in XMP metadata in Java and .NET.

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.