WebViewer Version: 10
Do you have an issue with a specific file(s)? No
Can you reproduce using one of our samples or online demos? No
Are you using the WebViewer server? No
Does the issue only happen on certain browsers? No
Is your issue related to a front-end framework? No
Is your issue related to annotations? Yes
Please give a brief summary of your issue:
Getting error while trying to import annotations with await annotationManager.importAnnotations
Please describe your issue and provide steps to reproduce it:
While trying webviewer SDK, we are trying to export and import highlight annotation with XML String.
It works fine with simple highlight. However when we add comment to a highlight and then try to import exported xfdf string we are getting below error.
VM6102:1 Uncaught (in promise) SyntaxError: Expected ‘,’ or ‘}’ after property value in JSON at position 157
at JSON.parse ()
at z.wS (webviewer-core.min.js:2576:292)
at n (webviewer-core.min.js:2579:108)…
Usage is pretty simple.
const ymlString = <?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="4" /><fields /><annots><highlight page="2" rect="101.823,546.447,289.804,614.990" color="#FFCD45" flags="print" name="acdb94cb-47d1-70b6-5471-c0329260262b" title="Kapil" subject="Highlight" date="D:20230331170302+05'30'" creationdate="D:20230331170217+05'30'" coords="101.8356141564941,614.9903058593754,280.6261340864942,614.7917807493757,101.82287281494138,603.4943585937494,280.6133927449414,603.2958334837497,101.8385160564941,595.9942792593754,289.8041073864943,595.7855663493757,101.82577471494137,584.4983319937496,289.7913660449416,584.2896190837499,101.8414179564941,576.9982526593758,285.9010160964942,576.7938768793756,101.82867661494137,565.5023053937498,285.88827475494145,565.2979296137496,101.84431985649412,558.0022260593753,155.14717264649414,557.9430397293752,101.8315785149414,546.5062787937501,155.1344313049414,546.4470924637501"><trn-custom-data bytes="{"trn-annot-preview":"A first mistake organizations make when selecting a PDF library for the first time is to assume fixed feature requireme","trn-mention":"{\"contents\":\"Some test comment\\n\\n\",\"ids\":[]}","trn-attachments":"[]"}"/><contents>Some test comment</contents><contents-richtext><body><p><span>Some test comment</span></p></body></contents-richtext></highlight></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
;
in component after loading the document and annotations we try to import above xfdf string (which was exported via the document itself)
documentViewer.addEventListener(‘annotationsLoaded’, async () => {
const annotations = await annotationManager.importAnnotations(ymlString); // this is where error occurs
annotations.forEach((annotation) => {
console.log(annotation);
annotationManager.redrawAnnotation(annotation);
});
});
I guess the problem is with below snippet in the xfdf.
<trn-custom-data bytes="{"trn-annot-preview":"A first mistake organizations make when selecting a PDF library for the first time is to assume fixed feature requireme","trn-mention":"{\"contents\":\"Some test comment\\n\\n\",\"ids\":[]}","trn-attachments":"[]"}"/>