Add properties in XMP metadata of EPS | JavaScript
To add properties in XMP metadata of an EPS file, it is necessary to do several steps:
- Create file reader ‘const file_reader = new FileReader();’ and read file ‘file_reader.readAsArrayBuffer(e.target.files[0]);’.
- On load event handler call AsposeXMPAddSimpleProperties and pass the file content, his name, result file name, prefix, url, and property key and value to it.
- The result JSON contains the file name in fileNameResult.
- 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 an XML namespace in XMP metadata in an EPS file in JavaScript via C++:
1 var fXMPAddSimpleProperties = function (e) {
2 const file_reader = new FileReader();
3 file_reader.onload = (event) => {
4 const key = "tmp:newKey"
5 const value = "NewValue"
6 const JSON = AsposeXMPAddSimpleProperties(event.target.result, e.target.files[0].name, e.target.files[0].name + "_out.eps", key, value);
7 if (JSON.errorCode == 0) {
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 }
You can download examples and data files from GitHub.