Unknown XFDF element 'text'

Unable to import annotations from XFDF to PDF when annotation contains element.
Error message : Unknown XFDF element 'text'

We are using Aspose PDF for Java 11.5.0

<text page="0" color="#F2DD47" date="D:20160519161606Z" title="Migliu" rect="137.310000,542.600000,169.310000,574.600000" flags="print" name="B7B1EF63-50E3-45F9-8C3F-15515A004568" creationdate="D:20160519161558Z" opacity="1" rotation="0" icon="Comment">

<body xmlns="http://www.w3.org/1999/xhtml" xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xfa:APIVersion="Acrobat:11.0.12" xfa:spec="2.0.2">

A note







It looks like the problem is not in the element itself but with the previous element that has no separate enclosing tag, only />.

Hi Alexander,


Thanks for contacting support.

From your above reply, it appears that you have managed to figure out the problem and it appears to be resolved. In case you are still facing the same issue, please share the resource files.
The problem is not resolved, unfortunately - I just found the reason why it happens. I think it's related to the problem described for the similar .NET component here

https://forum.aspose.com/t/28050

When there is an empty/self-closing tag the next tag in XML is treated as a part of a previous one. In my case it's self-closed tag and then next tag which is considered as a part of .

The method that causes the problem is importAnnotationFromXfdf from PdfAnnotationEditor

Stack trace:

Unknown XFDF element 'text'
com.aspose.pdf.internal.ms.System.z8: Unknown XFDF element 'text'
at com.aspose.pdf.XfdfReader.m1(Unknown Source) ~[aspose-pdf-11.5.0.jar:11.5.0]
at com.aspose.pdf.LineAnnotation.m1(Unknown Source) ~[aspose-pdf-11.5.0.jar:11.5.0]
at com.aspose.pdf.XfdfReader.m1(Unknown Source) ~[aspose-pdf-11.5.0.jar:11.5.0]
at com.aspose.pdf.XfdfReader.readAnnotations(Unknown Source) ~[aspose-pdf-11.5.0.jar:11.5.0]
at com.aspose.pdf.facades.PdfAnnotationEditor.m2(Unknown Source) ~[aspose-pdf-11.5.0.jar:11.5.0]
at com.aspose.pdf.facades.PdfAnnotationEditor.importAnnotationFromXfdf(Unknown Source) ~[aspose-pdf-11.5.0.jar:11.5.0]

Attached the XFDF file that causing the problem.

Thanks!




Hi Alexander,


Thanks for sharing the resource file.

In order for us to replicate this problem, we request you to please share the input PDF document. We are sorry for this inconvenience.

Hi Nayyer,

Sent via email. Please check.

Thank you,
Alexander.

Hi Alexander,


Thanks for sharing the resource files.

We are working on testing the scenario using these documents and will get back to you soon.

Hi Alexander,


Thanks for using our API’s.

I have tested the scenario and have managed to reproduce same problem. For the sake of correction, I have logged it as PDFJAVA-35890 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.

The issues you have found earlier (filed as PDFJAVA-35890) have been fixed in Aspose.PDF for Java 26.1.