Get XMP metadata from EPS file using JavaScript

To extract XMP metadata from 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 AsposeEPSGetXMP and pass the file content, its 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 extract XMP metadata from EPS file in JavaScript:

 1  // Get XMP metadata. 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)
 2  var fGetXmpMetadata = function (e) {
 3    const file_reader = new FileReader();
 4    file_reader.onload = (event) => {
 5      const JSON = EPSGetXMP(event.target.result, e.target.files[0].name, e.target.files[0].name + "_out.eps");
 6      if (JSON.errorCode == 0) {
 7          document.getElementById('output').textContent = JSON.XMP;
 8          DownloadFile(JSON.fileNameResult, "image/eps");
 9      }
10      else 
11        document.getElementById('output').textContent = JSON.errorText;
12    }
13    file_reader.readAsArrayBuffer(e.target.files[0]);
14  }

See extracting 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.