Skip to main content
Inspiring
March 17, 2023
Question

ANNOTATION_ADDED event triggering on load

  • March 17, 2023
  • 5 replies
  • 1436 views

ANNOTATION_ADDED event triggering on load when loading the pdf viewer in my application.

 

I have a unique constraint on my database, and every time the PDF loads, my annotations trigger an ANNOTATION_ADDED notification which tries to insert the record.

 

Annotation Added should not trigger when annotations are loaded into the PDF but rather when an annotation is added into the PDF after it's loaded existing annotations.

 

Please advise, thanks.

    This topic has been closed for replies.

    5 replies

    Raymond Camden
    Community Manager
    Community Manager
    June 9, 2023

    Can you provide more information? Are you loading into Embed a PDF with existing annotations? Are you dymanically adding new ones?

    Inspiring
    June 9, 2023

    The annotations are in database, here is the code when the user loads a pdf..

     

    adobeDCView.previewFile({
    		content: { location: { url: url } },
    		metaData: { fileName: fileName, id: id, hasReadOnlyAccess: readOnly }
    	}, options)
    		.then((view) => {
    			view.getAnnotationManager().then((annotationManager) => {
    				if (!readOnly) {
    					annotationManager.setConfig(annotationManagerConfig);
    
    					annotationManager.addAnnotationsInPDF(list_of_annotations)
    						.then(result => console.log(result))
    						.catch(error => console.log(error));
    
    					annotationManager.registerEventListener(async function (event) {
    						if (event.type == "ANNOTATION_MODE_STARTED" || event.type == "ANNOTATION_CLICKED") {
    							if (event.data == "freetext") {
    								annotationManager.endAnnotationMode();
    								window.alert("Annotation Type is not currently supported.");
    								return;
    							}
    						}
    						else {
    							if (event.data.creator.id != email) {
    								annotationManager.unselectAnnotation();
    							}
    							else {
    								if (event.data?.target?.selector?.subtype == "freetext") {
    									annotationManager.endAnnotationMode();
    								}
    								else {
    									await GLOBAL.DotNetReference.invokeMethodAsync('ReceiveAnnotationEvent', event);
    								}
    							}
    						}
    					}, eventOptions);
    				}
    		});
    Inspiring
    June 9, 2023

    the event listener is registered after add annotations in pdf executes

    Inspiring
    June 9, 2023

    @Raymond Camden please can you provide any input

    Inspiring
    June 9, 2023

    BUMP PLEASE

    Inspiring
    May 8, 2023

    BUMP PLEASE

    Inspiring
    April 11, 2023

    BUMP