hi Kevin,
i tried both ways for rendering data back to PDF, it works for 1 or 2 times, 3rd time it doesnt bind back annotations for 1 and 2 pages,
selectAllAnnotations(annotationList: any) {
for (let i = 0; i < annotationList.length; i++) {
setTimeout(() => {
this.setAnnotation(annotationList[i]);
});
}
// this.setAllAnnotationEvent.emit();
}
WebViewer(
{
path: '../../wv-resources/lib',
},
this.viewer.nativeElement
).then((instance: any) => {
const { documentViewer, annotationManager, Annotations } = instance.Core;
annotationManager.addEventListener('annotationChanged', (annotations: any, action: any) => {
// logic based on checkbox checked single
this.setAnnotationEvent.subscribe(() => {
instance.UI.setToolbarGroup('toolbarGroup-Insert');
const annotationsList = annotationManager.getAnnotationsList();
const xfdfString = this.renderingInstance;
annotationManager.importAnnotations(xfdfString);
this.renderingInstance = '';
let isChecked: any = [...this.annotationList.filter((ele: any) => ele.checked)];
if (isChecked.length > 0) {
instance.UI.disableElements(['ribbons']);
} else {
instance.UI.enableElements(['ribbons']);
}
instance.UI.setToolbarGroup('toolbarGroup-Insert');
});
// set all annotations
this.setAllAnnotationEvent.subscribe(() => {
const annotationsList = annotationManager.getAnnotationsList();
if (annotationsList.length > 0) {
if (this.addButtonPermission) {
annotationManager.deleteAnnotations(annotationsList);
} else {
annotationManager.hideAnnotations(annotationsList);
}
}
const importedAnnotations = [];
instance.UI.setToolbarGroup('toolbarGroup-Insert');
for (let i = 0; i < this.annotationList.length; i++) {
this.renderingInstance = this.annotationList[i].xfdfData;
const annotation = annotationManager.importAnnotations(this.annotationList[i].xfdfData);
importedAnnotations.push(annotation);
annotationManager.importAnnotations(importedAnnotations);
}
});
});
XML Data:
<?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><square page="0" rect="231,610,464,675" color="#E44234" flags="print" name="c8f0a504-3609-d257-055e-03604a164502" title="admin" subject="Rectangle" date="D:20220921184525+05'30'" creationdate="D:20220921184525+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="0" rect="112,621,430,719" color="#E44234" flags="print" name="669cb942-45c2-b3cc-0c4e-e52752cbd9aa" title="admin" subject="Rectangle" date="D:20220921153109+05'30'" creationdate="D:20220921153108+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="0" rect="104,623,481,700" color="#E44234" flags="print" name="81d167d4-73bd-250e-a99c-9cdda54d1b2d" title="admin" subject="Rectangle" date="D:20220921115756+05'30'" creationdate="D:20220921115755+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="0" rect="68,619,536,721" color="#E44234" flags="print" name="655adb9b-df81-3c6b-9878-b37f5aff933b" title="admin" subject="Rectangle" date="D:20220921110757+05'30'" creationdate="D:20220921110756+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="0" rect="100,405,570,732" color="#E44234" flags="print" name="bb0ac255-b0ff-7c51-5e6e-e0a7d57c04a0" title="admin" subject="Rectangle" date="D:20220921154019+05'30'" creationdate="D:20220921154018+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="0" rect="122,604,496,726" color="#E44234" flags="print" name="a5f1bd05-cd8c-76a6-d3ad-56e1e3355bf5" title="admin" subject="Rectangle" date="D:20220923162824+05'30'" creationdate="D:20220923162823+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="0" rect="68,32,429,62" color="#E44234" flags="print" name="108119f6-efde-f30a-f86e-3129585734d9" title="admin" subject="Rectangle" date="D:20220923155008+05'30'" creationdate="D:20220923155007+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="1" rect="110,467,518,639" color="#E44234" flags="print" name="cb9b40a8-5b25-a0b2-98ea-dd82512502e1" title="admin" subject="Rectangle" date="D:20220921110821+05'30'" creationdate="D:20220921110821+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="42,97,83,108" color="#E44234" flags="print" name="40bae075-6cf8-2844-0026-870c9e55798b" title="admin" subject="Rectangle" date="D:20220923155233+05'30'" creationdate="D:20220923155233+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="444,74,561,101" color="#E44234" flags="print" name="6285d642-3d45-a324-f3cd-2b8e7524eb8f" title="admin" subject="Rectangle" date="D:20220923155053+05'30'" creationdate="D:20220923155052+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="169,765,224,777" color="#E44234" flags="print" name="48bdce4b-8dc4-48a8-3c1c-01c6ce542077" title="admin" subject="Rectangle" date="D:20220923162847+05'30'" creationdate="D:20220923162846+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="127,47,200,61" color="#E44234" flags="print" name="fd72c07f-d677-6c2d-f558-4a2e4aa6bb62" title="admin" subject="Rectangle" date="D:20220923155513+05'30'" creationdate="D:20220923155513+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="240,366,416,448" color="#E44234" flags="print" name="85a478b5-6582-ec90-097c-9e696df084ed" title="admin" subject="Rectangle" date="D:20220923123426+05'30'" creationdate="D:20220923123425+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="84,676,453,729" color="#E44234" flags="print" name="b4fa3f3d-8497-2e45-6b4a-f88d45235c8b" title="admin" subject="Rectangle" date="D:20220923123407+05'30'" creationdate="D:20220923123403+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="569,376,598,660" color="#E44234" flags="print" name="f3a0dcd9-a0a5-c0dd-90ce-5780c2794b7c" title="admin" subject="Rectangle" date="D:20220923173222+05'30'" creationdate="D:20220923173221+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="72,129,564,321" color="#E44234" flags="print" name="9af0ce01-4a1d-031f-9fd6-955fbb808d69" title="admin" subject="Rectangle" date="D:20220923160627+05'30'" creationdate="D:20220923160626+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>
<?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><square page="2" rect="25,599,31,615" color="#E44234" flags="print" name="34e02210-3992-bfc6-f0dd-c1fa522e65d4" title="admin" subject="Rectangle" date="D:20220923162855+05'30'" creationdate="D:20220923162854+05'30'"/></annots><pages><defmtx matrix="1,0,0,-1,0,792" /></pages></xfdf>