Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Problem setting "XmpPdfAExtensionValueType" in aspose.pdf

$
0
0
Hello,

we are using Aspose.Pdf (.Net) to convert PDF to PDF-A and to add custom XMP-Metadata.
We like to add structured metadata, and so we want to define a XmpPdfAExtensionValueType and add the XmpPdfAExtensionProperties to this.

When we add the XmpPdfAExtensionValueType to the Document.Metadata and try to save the Document, we get a
“System.InvalidOperationException: Cannot set a value on node type 'Element'”

When we add XmpPdfAExtensionProperties directly to the Metadata, everything works fine, but we have no custom value type.

This is independent on whether we convert the PDF to PDF/A or not.


Here is a minimal example:
static void Main(string[] args)
{
Aspose.Pdf.License pdflicense = new Aspose.Pdf.License();
pdflicense.SetLicense("Aspose.Pdf.lic");
if (!Aspose.Pdf.Document.IsLicensed)
{
throw new Exception("Can not license Aspose.PDF");
}

Pdf pdf = new Pdf();
Section sec = pdf.Sections.Add();
sec.Paragraphs.Add(new Text("Hello World"));


Document doc = new Document(pdf);

XmpPdfAExtensionValueType vt = new XmpPdfAExtensionValueType("Testtype", "http://www.aiim.org/pdfa/ns/type#", "pdfaType", "Desc Type");
XmpPdfAExtensionProperty prop1=new XmpPdfAExtensionProperty("prop1", "Value1", "Text", XmpPdfAExtensionCategoryType.External, "dec1");
XmpPdfAExtensionProperty prop2 = new XmpPdfAExtensionProperty("prop2", "Value2", "Text", XmpPdfAExtensionCategoryType.External, "dec2");
vt.Add(prop1);
vt.Add(prop2);

String prefix = "myprefix";
doc.Metadata.RegisterNamespaceUri(prefix, "http://www.foobar.com/mynamespace", "Namespace Description");
doc.Metadata.Add(prefix,vt);
doc.Save("test.pdf"); //here the error occurs
}

The problem is present in Version 10.7.0.0 and 10.8.0.0.
Any advice is highly appreciated.

Thanks for your Support.

Kind regards
M. Schröther

Viewing all articles
Browse latest Browse all 3131

Trending Articles