Manipulate XMP Metadata
Unlock a new level of control over your EPS (Encapsulated PostScript) files with our powerful JavaScript API solution! Seamlessly read, write, and update XMP metadata directly within your applications.
Tired of manual metadata entry for your EPS files? Our JavaScript API solution offers a groundbreaking way to programmatically code XMP metadata for your Encapsulated PostScript documents. XMP (Extensible Metadata Platform) is crucial for asset management, searchability, and preserving valuable information like author, copyright, keywords, and more. Our API empowers you to programmatically manage this critical information, ensuring your EPS assets are always organized, discoverable, and correctly attributed. For more information and examples on working with XMP metadata, visit the Aspose.Page API documentation on GitHub . Try also our XMP Metadata Editor web app, to see how the functionality may be used.
To run the code example, you will need:
- Aspose.Page for JavaScript API, which is a feature-rich, powerful, and easy-to-use document manipulation and conversion API for JavaScript solution.
- Download its latest version directly from releases page , and follow instruction to install.
Get/Add XMP metadata to an EPS file with JavaScript
To insert XMP metadata to EPS, you will need to take the next steps:
- Create file reader ‘const file_reader = new FileReader();’ and read file ‘file_reader.readAsArrayBuffer(e.target.files[0]);’.
- On load event handler call AsposeEPSGetXMP and pass the file content and its name, new size as width and height, and unit type to it.
- 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).
- The result JSON contains the file name in fileNameResult.
- You can download a file by using the DownloadFile function: ‘DownloadFile(json.fileNameResult, ‘image/eps’);’.
Get/Add XMP metadata
var fGetXmpMetadata = function (e) {
const file_reader = new FileReader();
file_reader.onload = (event) => {
const json = AsposeEPSGetXMP(event.target.result, e.target.files[0].name, e.target.files[0].name + '_out.eps');
if (json.errorCode == 0) {
document.getElementById('output').textContent = json.XMP;
DownloadFile(json.fileNameResult, 'image/eps');
}
else
document.getElementById('output').textContent = json.errorText;
}
file_reader.readAsArrayBuffer(e.target.files[0]);
}
Add an arrray items of XMP metadata to EPS file with JavaScript
- Create file reader ‘const file_reader = new FileReader();’ and read file ‘file_reader.readAsArrayBuffer(e.target.files[0]);’.
- On load event handler call AsposeXMPAddArrayItem and pass the file content and its name, and an array of key and value pairs to it.
- The result JSON contains the file name in fileNameResult and xmp metadata in XMP field.
- You can get data ‘document.getElementById(‘output’).textContent = json.XMP;’
- Also, you can download a file by using the DownloadFile function: ‘DownloadFile(json.fileNameResult, ‘image/eps’);’.
Add array items
var fGetXmpMetadata = function (e) {
const file_reader = new FileReader();
file_reader.onload = (event) => {
const input = [
['dc:title', 'NewTitle'],
['dc:creator', 'NewCreator']
];
const json = AsposeXMPAddArrayItem(event.target.result, e.target.files[0].name, e.target.files[0].name + '_out.eps', input);
if (json.errorCode == 0) {
DownloadFile(json.fileNameResult, 'image/eps');
}
else
document.getElementById('output').textContent = json.errorText;
}
file_reader.readAsArrayBuffer(e.target.files[0]);
}
Also, you can learn about other XMP metadata functions in articles documentation articles:
EPS What is EPS File Format
EPS (EPSF) or Encapsulated PostScript File Format is the format that is actually a PS program that describes what would a single page look like. It is actually limited PS plus particular notes that help encapsulate PostScript graphics to another document. EPS perfectly supports vector graphics or combined vector-raster graphics. The peculiarity of the format is that as soon as it is imported into a document, it cannot be edited anymore. That is one of the reasons to convert this format to the one you are able to work with.