Is it possible to use exportAnnotations to export individual widgets and fields

|UI version|7.3.0|
|Core version|7.3.1|

Detailed description of issue
When I use the exportAnnotations() with annotList to export a single annotation that has field and widget, the export gives all documents annotation fields and widgets.

Expected behaviour
Expected to only have the fields and widgets for that annotation

Does your issue happen with every document, or just one?
Yes, not document related, only related to the annotation on the document.

Link to document
{Provide a link to the document in question if possible}

Code snippet

function saveAnnotation(annot) {
        if (annot instanceof Annotations.WidgetAnnotation) {
          var field = annot.fieldName;
          //var name = annot.Id;
          var type = "WidgetAnnotation";
          var assigned_team = annot.getCustomData("teamID");
          var question = annot.getCustomData("question");
          var answer = annot.value;
        } else if (annot instanceof Annotations.Annotation) {
          //var name = annot.Id;
          var type = "Annotation";
        }
        // Saves the annotations.
        annotManager
          .exportAnnotations({
            annotList: [annot],
            widgets: true,
            links: true,
            fields: true,
          })
          .then((xfdf) => {
            var annotation = {
              annotation: xfdf,
              created_by: "",
              name: annot.Id,
              field: field,
              type: type,
              assigned_team: assigned_team,
              question: question,
              answer: answer,
              document_key: props.document.id,
            };
            props.saveAnnotation(annotation);
          });
      }
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<xfdf xmlns=\"http://ns.adobe.com/xfdf/\" xml:space=\"preserve\">
	<pdf-info xmlns=\"http://www.pdftron.com/pdfinfo\" version=\"2\" import-version=\"3\">
		<ffield type=\"Tx\" name=\"219d6ca0-187e-867a-f01f-45296f3717c10\" flags=\"Required\"/>
		<ffield type=\"Tx\" name=\"219d6ca0-187e-867a-f01f-45296f3717c11\" flags=\"Required\"/>
		<widget field=\"219d6ca0-187e-867a-f01f-45296f3717c10\" modified-date=\"D:20210825133235-07'00'\" page=\"1\">
			<rect x1=\"221.2892\" x2=\"317.8377\" y1=\"753.7668\" y2=\"773.0765\"/>
			<border width=\"0\" style=\"null\">
				<color a=\"0\"/>
			</border>
			<trn-custom-data bytes=\"{&quot;team&quot;:&quot;Phase Team&quot;,&quot;required&quot;:true,&quot;checked&quot;:&quot;&quot;,&quot;question&quot;:&quot;q?&quot;,&quot;teamID&quot;:&quot;8&quot;}\"/>
		</widget>
		<widget field=\"219d6ca0-187e-867a-f01f-45296f3717c11\" modified-date=\"D:20210825133238-07'00'\" page=\"1\">
			<rect x1=\"221.2892\" x2=\"317.8377\" y1=\"753.7668\" y2=\"773.0765\"/>
			<border width=\"0\" style=\"null\">
				<color a=\"0\"/>
			</border>
			<trn-custom-data bytes=\"{&quot;team&quot;:&quot;Phase Team&quot;,&quot;required&quot;:true,&quot;checked&quot;:&quot;&quot;,&quot;question&quot;:&quot;q?&quot;,&quot;teamID&quot;:&quot;9&quot;}\"/>
		</widget>
	</pdf-info>
	<fields>
		<field name=\"219d6ca0-187e-867a-f01f-45296f3717c10\">
			<value/>
		</field>
		<field name=\"219d6ca0-187e-867a-f01f-45296f3717c11\">
			<value/>
		</field>
	</fields>
	<annots/>
</xfdf>"

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Hi Slavko,

Interestingly this is the expected behavior as even though we call widgets annotations in our API they are technically not annotations. You can see this reflected in the XFDF you shared the annots tag is empty <annots/> We don’t have an API to get the XFDF for one widget but we can use DOMParser to parse out a specific widget from the XML

Here’s a code snippet of that:

    const annots = annotManager.getAnnotationsList();
    const singleAnnot = annots.find(annot => annot instanceof Annotations.WidgetAnnotation);

    const name = singleAnnot.fieldName


    const xfdf = await annotManager.exportAnnotations({
      annotList: [singleAnnot],
      widgets: true,
      links: true,
      fields: true,
    })
    const parser = new DOMParser();
    const xmlDoc = parser.parseFromString(xfdf, "text/xml");
    console.log(xmlDoc.querySelector(`ffield[name='${name}']`));

Cheers,
Dustin

1 Like