Product: PDFtron for angular
Product Version: Version: 8.9.0
Please give a brief summary of your issue:
I am importing my annotations from a database where I have previously stored xfdf. Now when I am importing the annotations I use const annotations = this.webViewerInstance.Core.annotationManager.importAnnotations(xfdfString).
Here from the annotations variable I show only a certain annotations based on some condition and hide other annotations.This is working as expected but there is slight delay between the import and hide so it flickers the annotation and then hide it.(All the annotations get displayed first and after some seconds hideannotations() work so it feels like a flicker).
Can I have an alternative to hide the required annotations and after that only the annotations are visible on the document.
Hello Pranay,
Could you provide a complete code snippet of how you are importing and hiding the annotations?
Best Regards,
Darian
the xfdfString is the response I get from api and this.hideannotations is an empty array at start and this code is written in onDocumentLoaded:-
const annotations = await annotationManager.importAnnotations(xfdfString);
annotations.forEach((ele,index)=>{
if(some condition matches){
this.hideannotations.push(ele);
}
})
after the loop I use
this.webViewerInstance.Core.annotationManager.hideAnnotations(this.hideannotations)
Hello Pranay,
You can listen for the annotationChanged
event and hide the annotations when they are added.
Here is an example that hides rectangle annotations without any flicker.
annotationManager.addEventListener('annotationChanged', async (annotations, action) => {
if (action === 'add') {
annotations.forEach(annotation => {
if (annotation instanceof Annotations.RectangleAnnotation) {
annotationManager.hideAnnotation(annotation);
}
});
}
});
Best Regards,
Darian