Q:
How can I get the XFDF data from a specific list of annotations and not all annotations?
A:
Unfortunately it's not completely straightforward to get the XFDF data from a single annotation, but there is a roundabout way that you can do it:
function getXFDFData(annots) {
var annotManager = readerControl.docViewer.GetAnnotationManager();
var serializer = new XMLSerializer();
var xfdfData = '';
var serialize = Annotations.Annotation.prototype.serialize;
Annotations.Annotation.prototype.serialize = function(element, pageMatrix, isExport) {
if (isExport) {
if (annots.indexOf(this) !== -1) {
var annotEl = this.serialize(element, pageMatrix);
xfdfData += serializer.serializeToString(annotEl);
}
}
return serialize.apply(this, arguments);
};
// trigger the calling of serialize on all the annotations
annotManager.ExportAnnotations();
// set serialize back to the original function
Annotations.Annotation.prototype.serialize = serialize;
return xfdfData;
}
var myData = getXFDFData(myAnnotList);
You would pass an array of annotations into the getXFDFData function and it would return their XFDF data in string format.