# Field values not encoded properly

**URL:** <https://pdfjs.community/t/field-values-not-encoded-properly/380>\
**Category:** Technical Support\
**Tags:** pdfjs-express\
**Created:** [November 3, 2020, 2:59pm UTC](https://pdfjs.community/t/field-values-not-encoded-properly/380 "2020-11-03T14:59:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwithers](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jwithers](https://pdfjs.community/u/jwithers)\
**Post date:** [November 3, 2020, 2:59pm UTC](https://pdfjs.community/t/field-values-not-encoded-properly/380/1 "2020-11-03T14:59:12Z")

</div>

**PDF.js Express Version**  
7.0.1

**Detailed description of issue**  
XFDF created by exporting annotations does not produce proper XML encoded field values.

Example xfdf string produced with invalid xml encoding:  
`<?xml version="1.0" encoding="UTF-8" ?><xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"><fields><field name="FLD_CUSTOMER_BANK_NAME"><value>Test Bank & Trust</value></field></fields><annots /><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>`

Notice & value in FLD\_CUSTOMER\_BANK\_NAME value

**Expected behaviour**  
Field values should have XML entities encoded properly so other XML parsers can consume the data.

Expected XML:  
`<?xml version="1.0" encoding="UTF-8" ?><xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve"><fields><field name="FLD_CUSTOMER_BANK_NAME"><value>Test Bank &amp; Trust</value></field></fields><annots /><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>`

**Does your issue happen with every document, or just one?**  
All documents

**Link to document**  
n/a

**Code snippet**  
viewer.viewerInstance.annotManager.exportAnnotations({ links: false, widgets: false }).then(function (x) {  
console.log(“xfdf data=” + x);  
});

---

<div class="post-metadata">

**Author:** ![Logan](https://yyz1.discourse-cdn.com/flex031/user_avatar/pdfjs.community/logan/32/13_2.png) [@Logan](https://pdfjs.community/u/Logan)\
**Post date:** [November 4, 2020, 5:53pm UTC](https://pdfjs.community/t/field-values-not-encoded-properly/380/2 "2020-11-04T17:53:15Z")

</div>

Hi there,

We can not reproduce this issue on our end. Would you be able to send us the file you tested with?

Thanks!  
Logan

---

<div class="post-metadata">

**Author:** ![jwithers](https://avatars.discourse-cdn.com/v4/letter/j/67e7ee/32.png) [@jwithers](https://pdfjs.community/u/jwithers)\
**Post date:** [November 4, 2020, 6:26pm UTC](https://pdfjs.community/t/field-values-not-encoded-properly/380/3 "2020-11-04T18:26:40Z")

</div>

My apologies, Logan.

It does appear that when getting the xfdf data from the document the field value are encoded properly. I guess there’s something else going on between the submission and recording of this data I need to track down.

Thanks for the reply.
