Skip to main content
Inspiring
December 10, 2020
Question

How to control the Edit and Delete Event of Annotation of PDF Embed API.

  • December 10, 2020
  • 1 reply
  • 1978 views

Hi, I am using PDF Embed API for the web application wanted to get control of the Delete Action of the Annotation.
Why I would need this is listed below:


Imagine I am logged in as a User called "Amit" and added some annotation, this annotated value is stored in my local collection and logged out of the application.
The user called "Akash" logged in and see that the annotation is added to the PDF and he try to delete the annotation what "Amit" has added using the Delete Option in the  Drop Down.

I wanted to have control over the Delete Action before the Annotation is actually deleted.
I am listening to the Event Listener as 

adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
        function(event) {
            console.log(event.typeevent.data)
            if(event.type === "ANNOTATION_DELETED"){
                if(event.data.creator.id != loggedInUserInfo.users._id){
                    $.alertable.alert("Can not delete "event.data.creator.name +"'s comment.");
                    return false;
                }
                else{
                    annotationUpdated(event);
                }
            } 
        }, eventOptions
    );
 
Not that I am not storing the Annotated Value in the PDF Buffer, rather storing it locally.
The Above logic work fine as it is not calling annotationUpdated() and when I do the reload it is actually getting it back. But this does not sound user friendly for me.

Please let me know how can I handle the EDIT and DELETE Option from the UI. 
Or for the alternate do let me know How to hide those options from UI.

Thanks.
    This topic has been closed for replies.

    1 reply

    Joel Geraci
    Community Expert
    Community Expert
    December 10, 2020

    I have an example at this CodePen that shows how to immediately deselect an annotation that was selected by someone other than the author. If it can't be selected, it can't be deleted.

    Dhruv5CCFAuthor
    Inspiring
    December 11, 2020

    Hi Joel, 
    Thanks for the reply.

    The above-mentioned example will not allow me to complete my workflow ie, to reply to the comment.
    When a user comments, the other user will also reply to the comment added by the previous user.

     

    That's why I would need control on how to handle the EDIT and DELETE Options from UI.

    Joel Geraci
    Community Expert
    Community Expert
    December 11, 2020

    In that case. My suggestion would be to listen for "ANNOTATION_SELECTED" and if the author isn't the user, pop up a dialog where they can capture the reply text (or cancel) and then programmatically add the reply.

     

    I've already submitted a feature request to "lock" annotations from other users but haven't heard an update on the request.