How to embed and extract blank data in XMP

Hi Aspose,

I tried to embed a blank data in the metadata(xmp) by using Aspose.pdf for .net.(version 6.2). However, i can not extract the blank metadata from saved file.

Below is the code to render.

// Set Lisence Info
var aspose = new License();
aspose.SetLicense("Aspose.Pdf.lic");

// Open source pdf file
var document = new Document(Path.Combine(binDir.FullName, "prereport.pdf"));
document.Metadata.RegisterNamespaceUri("tw", "http://ns.adobe.com/xap/1.0/abc");
// Push 2 key value pairs, one with value, the other blank
document.Metadata["tw:key1"] = "value1";
document.Metadata["tw:key2"] = string.Empty;

// Save to a file
document.Save(Path.Combine(binDir.FullName, "out.pdf"));
// Open the saved file
var newDocument = new Document(Path.Combine(binDir.FullName, "out.pdf"));

// Assert the saved value, the one with "value1" can be read correctly
Assert.True(newDocument.Metadata.Contains("tw:key1"));
Assert.Equal("value1", newDocument.Metadata["tw:key1"]);
// But the one with blank value lost,this assert fails
Assert.True(newDocument.Metadata.Contains("tw:key2"));
// Same things happens on which value is white spaces

Please help.

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

<o:p> </o:p>

Thank you for sharing the sample code.<o:p></o:p>

<o:p> </o:p>

I tested your issue with the latest version of Aspose.Pdf
for .NET v7.2 and it does not support to add an xmp metadata with empty value at the
moment. I further tested your issue with
Adobe X to make sure that this functionality is support but as per my findings
Adobe X does not allow it either. I added an empty node in the xmp file and
imported it using Adobe X, it does not import that field in the PDF file. However,
for further investigation on the support of this feature, I have created an
issue in our issue tracking system with issue id: PDFNEWNET-34198 for
our development team to further investigate it and share their feedback. As soon as I get a response, I will update you via this forum thread.

<o:p> </o:p><o:p> </o:p>

Sorry for the inconvenience,<o:p></o:p>

The issues you have found earlier (filed as PDFNEWNET-34198) have been fixed in Aspose.Pdf for .NET 8.0.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.