Product question: does Aspose support setting XMP metadata in EPS documents?

We’re looking for a library which we can use to set XMP metadata in EPS documents (at a document level, not an object level). Do any of the Aspose libraries offer this functionality?

@amytant

Could you please ZIP and attach your input and expected output EPS documents? We will then provide you more information on it.

@amytant

We have logged a feature request as PAGENET-344 in our issue tracking system to support setting XMP metadata in EPS document. We will inform you via this forum thread once this feature is available. We apologize for your inconvenience.

Thank you for logging this as a feature request. I have attached example input and expected out EPS documents. EPS_XMP.zip (449.0 KB)

In this attached example, the dc:title and xmp:MetadataDate properties within the XMP packet in the EPS document have been updated.

Further info on the feature request:

We want use a library to set metadata values in the XMP metadata of an input EPS document.

  1. If the input EPS document doesn’t contain an XMP packet, one is added before doing the previous steps.

  2. For each property value we wish to set in a namespace, we first check if the namespace exists within the XMP packet. If it doesn’t, it is added.

  3. Then we check if the property exists within the namespace, if it doesn’t the property is added to the namespace. Then its value is set.

To be clear, this is the same XMP functionality that is provided for image files in Aspose.Imaging, for PDF etc in Aspose.PDF and for PSD etc in Aspose.PSD. We are looking for feature parity with these other Aspose libraries for reading/writing XMP metadata in EPS files.

Documentation for how this works for EPS files is found in the XMP specifications. https://github.com/adobe/xmp-docs/blob/master/XMPSpecifications/XMPSpecificationPart3.pdf

@amytant

Thanks for sharing the detail. We have logged it in our issue tracking system. We will inform you via this forum thread once there is an update available on it.

I see that issue PAGENET-344 has been closed, does this mean that this feature will become available in Aspose?

@amytant

Your issue has been resolved and its fix is available in Aspose.Page for .NET 22.4. Please download it from here:

Download Aspose.Page for .NET 22.4

@tahir.manzoor Thank you for the information. We have begun testing the Aspose.Page.EPS.XMP library in Aspose.Page for .NET 22.4 with various EPS files and have encountered some major issues that currently prevent us from implementing this solution in our software.

Our test case: We load the EPS file, write some new properties in the DC namespace, overwrite dc:format and add a new namespace tmp, save the file, then load it again and check if everything has been saved in the file as expected.

Encountered issues:

After saving an EPS file with updated XMP metadata:

  1. Some EPS files seem to lose the initial file data. In some cases this is both the EPS data and the initial XMP metadata (if it wasn’t overwritten), then the output file only seems to contain the new XMP metadata. Otherwise the initial EPS data is gone but the initial XMP metadata’s still in the file. Aspose.Page can successfully load the file, but an EPS viewer just shows a blank image. See examples of input/output files for these cases in attachment OutputEPSFileLacksAllInputData.zip (1.8 MB)

  2. Some EPS files seem to lose the initial XMP metadata, but the file can be successfully loaded by Aspose.Page and successfully opened by an EPS viewer tool. See examples of input/output files for these cases in attachment OutputEPSFileLacksInitialXMPData.zip (4.3 MB)

Example code for updating the XMP metadata and saving the file with Aspose.Page:

> var value = <value>
> 
> using (System.IO.FileStream input = System.IO.File.OpenRead(localPath))
> {
> 	PsDocument psDocument = new PsDocument(input);
> 	XmpMetadata xmp = psDocument.GetXmpMetadata();
> 
> 	var epsDocumentNamespace = xmp.GetNamespaceUriByPrefix("dc");
> 
> 	if (String.IsNullOrEmpty(epsDocumentNamespace))
> 	{
> 		xmp.RegisterNamespaceUri("dc", "http://purl.org/dc/elements/1.1/");
> 	}
> 
> 	if (xmp.ContainsKey("dc:keywords"))
> 	{
> 		xmp["dc:keywords"] = value;
> 	}
> 	else
> 	{
> 		xmp.Add("dc:keywords", value);
> 	}
> 
> 	try
>     {
> 		using (System.IO.FileStream output = new System.IO.FileStream(action.OutputPath, FileMode.Create, FileAccess.Write))
> 		{
> 			psDocument.Save(output);
> 		}
> 	}
> 	finally
> 	{
> 		input.Close();
> 	}
> }

After saving an EPS file with updated XMP metadata and then attempting to load the EPS file and its XMP metadata:

  1. Some EPS files don’t seem to be able to be successfully loaded by Aspose.Page again. When attempting to load these files with the following code snippet, they never seem to finish loading and the memory usage keeps climbing by hundreds of megabytes while triggering garbage collection, leading to me believe there is some kind of stack overflow or memory leak bug happening. Could be related to the incorrect saving in issues 1-3. See examples in attachment OutputEPSFileCannotBeLoadedByAsposeAfterAsposeSave.zip (491.8 KB)

  2. Some EPS files don’t seem to be able to have their XMP metadata successfully loaded by Aspose.Page again. When attempting to load the files with the following code snippet, the load succeeds but the XMPMetadata object contains 0 results, though you can clearly see there are properties within the XMP packet. See examples of input/output files for these cases in attachment OutputEPSFileCannotHaveItsXMPLoadedByAspose.zip (965.2 KB)

Example code for loading the EPS file and its XMP metadata with Aspose.Page (after it’s already been previously updated and saved by Aspose.Page):

using (var stream = System.IO.File.OpenRead(localPath))
{
    PsDocument psDocument = new PsDocument(stream);
    XmpMetadata xmp = psDocument.GetXmpMetadata();
}

@amytant

We are working over your query and will get back to you soon.

@amytant

We have logged this problem in our issue tracking system as PAGENET-361. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor I see that issue PAGENET-361 has been closed, does this mean that the fix will be available in Aspose.Page for .NET 22.5?

@amytant

Yes, your understanding is correct. We will inform you via this forum thread once new release of Aspose.Page is available.

@tahir.manzoor We have tested the fix in Aspose.Page for .NET 22.6. The first three of the previously reported bugs appear to have been resolved when tested with the same files. However, the fourth one has been found again with another file, and we have also identified another bug which prevents us from implementing this solution in our software.

  1. Same issue as before, reproduced with a different file than before (initial file no longer exhibiting this behaviour):

After saving an EPS file with updated XMP metadata and then attempting to load the updated EPS file, some EPS files don’t seem to be able to have their XMP metadata successfully loaded by Aspose.Page anymore.

When attempting to load the files with the following code snippet, the load succeeds but the XMPMetadata object contains 0 results (and is also missing namespaces), though looking at the XMP packet data you can clearly see that these properties do exist.

See example in attachment OutputEPSFileCannotHaveItsXMPLoadedByAspose.zip (247.0 KB)

  1. Newly encountered issue:

The XMP properties of an EPS file typically contain a property with the EPS file’s thumbnail data (namespace http://ns.adobe.com/xap/1.0/g/img/ property xapGImg:image, within property xap:Thumbnails). This data contains hex codes (HTML line feed symbol).

When updating the XMP with latest Aspose library version, these hex codes seem to be converted into actual line feed characters (new line). This can be considered corruption of the XMP property’s data, and potentially could occur in the data of other XMP properties which contain " ".

Our test case: We load the EPS file, write some new properties in the DC namespace, overwrite dc:format, save the file, then load it again and check if everything has been updated and saved in the file as expected.

See examples in attachment OutputEPSFileContainsCorruptedXMPData.zip (1.2 MB)

Since it looks like the HTML entity got stripped out of my previous comment, to be clear, it’s this one: https://www.codetable.net/hex/a

These are being encoded to actual line feed characters in the output XMP data after Aspose.Page updates the XMP metadata of an EPS file.

@amytant

Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing. We will investigate the issue and provide you more information on it.

@tahir.manzoor

The standalone console application can be found here: AsposeEPSXMPApp.zip

After retesting with the standalone console application, I can confirm that issue 1 isn’t a bug anymore in Aspose.NET 22.6 after all. Issue 2 is still present and demonstrated by the console app, though.

@amytant

We have logged this problem in our issue tracking system as PAGENET-389. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor I see that PAGENET-389 was closed, but I don’t know if it was fixed and if so, when (in order to know which version of Aspose.Page the fix was added to). Can you provide this information?

@amytant

The issue has been fixed. We could not replicate it using the latest version of the API. Can you please try that and let us know in case you still notice any issues.