• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Annotation selector is not valid for given {id}

Explorer ,
Sep 30, 2022 Sep 30, 2022

Copy link to clipboard

Copied

Hi, 

I've encountered this error when using 

annotationManager.addAnnotations(annotations);

 It is really difficult to debug because it works fine on a PDF, until you add a certain annotation and then it stops working. From my best guess It seems to happen when the quadPoints contain more than 20+ items.

I will paste my full source code below.

Please advise urgently.

Kind regards

<script>
var document_data = [{
  "@context": [
    "https://www.w3.org/ns/anno.jsonld",
    "https://comments.acrobat.com/ns/anno.jsonld"
  ],
  "id": "4ababa2a-2de5-8e18-b0h9-c85939ab8a4",
  "type": "Annotation",
  "motivation": "commenting",
  "bodyValue": "hi",
  "target": {
    "source": "6d07d124-ac85-43b3-a867-36930f502ac6",
    "selector": {
      "node": {
        "index": 0
      },
      "opacity": 0.4,
      "subtype": "note",
      "boundingBox": [
        578,
        825,
        595,
        842
      ],
      "strokeColor": "#fccb00",
      "type": "AdobeAnnoSelector"
    }
  },
  "creator": {
    "id": "LMF-2",
    "name": "LMF-2",
    "type": "Person"
  },
  "created": "2022-09-30T08:55:18Z",
  "modified": "2022-09-30T08:55:18Z"
},{
  "@context": [
    "https://www.w3.org/ns/anno.jsonld",
    "https://comments.acrobat.com/ns/anno.jsonld"
  ],
  "id": "ebb99746-af83-8d67-55h1-9adbc9ac8a4",
  "type": "Annotation",
  "motivation": "commenting",
  "bodyValue": "hi2",
  "target": {
    "source": "6d07d124-ac85-43b3-a867-36930f502ac6",
    "selector": {
      "node": {
        "index": 0
      },
      "quadPoints": [
        90,
        684,
        506,
        684,
        90,
        671,
        506,
        671,
        90,
        671,
        385,
        671,
        90,
        657,
        385,
        657
      ],
      "opacity": 0.4,
      "subtype": "highlight",
      "boundingBox": [
        90,
        684,
        385,
        657
      ],
      "strokeColor": "#fccb00",
      "type": "AdobeAnnoSelector"
    }
  },
  "creator": {
    "id": "LMF-2",
    "name": "LMF-2",
    "type": "Person"
  },
  "created": "2022-09-30T08:55:38Z",
  "modified": "2022-09-30T08:55:38Z"
},{
  "@context": [
    "https://www.w3.org/ns/anno.jsonld",
    "https://comments.acrobat.com/ns/anno.jsonld"
  ],
  "id": "87b29110-8be8-813f-4bh3-c919ba82981",
  "type": "Annotation",
  "motivation": "commenting",
  "bodyValue": "",
  "target": {
    "source": "6d07d124-ac85-43b3-a867-36930f502ac6",
    "selector": {
      "node": {
        "index": 0
      },
      "quadPoints": [
        309.9162011173185,
        739.3463687150838,
        505.44692737430177,
        739.3463687150838,
        309.9162011173185,
        725.659217877095,
        505.44692737430177,
        725.659217877095,
        89.9441340782123,
        725.659217877095,
        505.44692737430177,
        725.659217877095,
        89.9441340782123,
        711.9720670391062,
        505.44692737430177,
        711.9720670391062,
        89.9441340782123,
        711.9720670391062,
        306.9832402234637,
        711.9720670391062,
        89.9441340782123,
        698.2849162011173,
        306.9832402234637,
        698.2849162011173
      ],
      "opacity": 0.4,
      "subtype": "highlight",
      "boundingBox": [
        309.9162011173185,
        739.3463687150838,
        306.9832402234637,
        698.2849162011173
      ],
      "strokeColor": "#fccb00",
      "type": "AdobeAnnoSelector"
    }
  },
  "creator": {
    "id": "LMF-2",
    "name": "LMF-2",
    "type": "Person"
  },
  "created": "2022-09-30T09:04:59Z",
  "modified": "2022-09-30T09:04:59Z"
},];

const annotations = document_data;
        
/*
Copyright 2020 Adobe
All Rights Reserved.

NOTICE: Adobe permits you to use, modify, and distribute this file in
accordance with the terms of the Adobe license agreement accompanying
it. If you have received this file from a source other than Adobe,
then your use, modification, or distribution of it requires the prior
written permission of Adobe.
*/

var viewerConfig = {
    /* Enable commenting APIs */
    enableAnnotationAPIs: true,  /* Default value is false */
    embedMode: "FULL_WINDOW",
};

/* Wait for Adobe Document Services PDF Embed API to be ready */
document.addEventListener("adobe_dc_view_sdk.ready", function () {
    
    const eventOptions = {
        listenOn: [
            "ANNOTATION_ADDED", "ANNOTATION_CLICKED",
            "ANNOTATION_UPDATED", "ANNOTATION_CLICKED",
            "ANNOTATION_DELETED", "ANNOTATION_CLICKED",
        ]
    }
                 
    const profile = {
       userProfile: {
           name: 'LMF-2',
       }
   };
    /* Initialize the AdobeDC View object */
    var adobeDCView = new AdobeDC.View({
        /* Pass your registered client id */
        clientId: "removed_for_security",
        /* Pass the div id in which PDF should be rendered */
        divId: "adobe-dc-view",
    });

    /* Invoke the file preview API on Adobe DC View object and return the Promise object */
    var previewFilePromise = adobeDCView.previewFile({
        /* Pass information on how to access the file */
        content: {
            /* Location of file where it is hosted */
            location: {
                url: "https://some.domain.com/public/s3_files/uploadsPy3quFjSCSQF8vNJ4tOSCDWxlJhCfh8QAP1Kr0OG.pdf",
                /*
                If the file URL requires some additional headers, then it can be passed as follows:-
                header: [
                    {
                        key: "<HEADER_KEY>",
                        value: "<HEADER_VALUE>",
                    }
                ]
                */
            },
        },
        /* Pass meta data of file */
        metaData: {
            /* file name */
            fileName: "Py3quFjSCSQF8vNJ4tOSCDWxlJhCfh8QAP1Kr0OG.pdf",
            /* file ID */
            id: "6d07d124-ac85-43b3-a867-36930f502ac6"
        }
    }, viewerConfig);
    
    adobeDCView.registerCallback(
        AdobeDC.View.Enum.CallbackType.GET_USER_PROFILE_API,
        function() {
           return new Promise((resolve, reject) => {
              resolve({
                 code: AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
                 data: profile
              });
           });
        },
    {});
    

    /* Use the annotation manager interface to invoke the commenting APIs*/
    previewFilePromise.then(function (adobeViewer) {
        
        adobeViewer.getAnnotationManager().then(function (annotationManager) {
            annotationManager.registerEventListener(
            function(event) {
                var status = true;
                for (let i = 0; i < annotations.length; i++) {
                  if(annotations[i].id == event.data.id){
                      status = false;
                  }
                }
                if(event.type == "ANNOTATION_DELETED" || event.type == "ANNOTATION_UPDATED"){

                    status = true;
                }
                // "ANNOTATION_UPDATED", "ANNOTATION_CLICKED",
                if(status) {
                    console.log(event);
                    console.log('qawsed');
                    var workflow_id = $('.workflow_id').val();
                    var document_data  = JSON.stringify(event.data, null, 2);
                    // var document_data  = event.data;
                    $.ajax({
                        url         : base_url+'/correspondence/pdf-comment-save',
                        type        : "post",
                        data: {
                            '_token'        : csrf_token,
                            'data'          : document_data,
                            'type'          : event.type,
                            'workflow_id'   : workflow_id
                        },
                        success     : function(data){
                            var response =  $.parseJSON(data);
                            if(response.status == true) {
                                showMessage('success',response.message);
                            } else {
                                showMessage('error',response.message);
                            } 
                        }
                    });
                }
                
            },
                eventOptions
            );
            /* API to add annotations */
            annotationManager.addAnnotations(annotations)
                .then(function () {
                    console.log("Annotations added through API successfully")
                })
                .catch(function (error) {
                    console.log(error)
                    // console.log('1');
                });

            /* API to get all annotations */
            annotationManager.getAnnotations()
                .then(function (result) {
                    console.log("GET all annotations", result)
                })
                .catch(function (error) {
                    console.log(error)
                    // console.log('2');
                });

            /* API to delete annotations based on annotation ID filter */
            var filter = {
                annotationIds: ["3adeae16-a868-4653-960e-613c048dddc5", "079d66a4-5ec2-4703-ae9d-30ccbb1aa84c"]
            };
            annotationManager.deleteAnnotations(filter)
                .then(function () {
                    console.log("Deleted annotations based on annotation ID filter.")
                })
                .catch(function (error) {
                    console.log(error)
                    // console.log('3');
                });

            /* API to delete annotations based on page range filter */
            filter = {
                pageRange: {
                    startPage: 4,
                    endPage: 6
                }
            };
            annotationManager.deleteAnnotations(filter)
                .then(function () {
                    console.log("Deleted annotations based on page range filter")
                })
                .catch(function (error) {
                    console.log(error)
                    // console.log('4');
                });

            /* API to get annotations after deletion */
            annotationManager.getAnnotations()
                .then(function (result) {
                    console.log("GET annotations result after deleting annotations", result)
                })
                .catch(function (error) {
                    console.log(error)
                    // console.log('5');
                });
        });
    });
});
</script>

Views

7.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

@Raymond Camden I took your simple codepen example, put it on my server with my key, and it works:

 

http://terminus.lapcominc.com:8000/ 

 

I took my example page and stripped out everything extraneous, but it still doesn't work with my key:

 

http://terminus.lapcominc.com:8000/index-orig.html 

 

If we can't get the old version to work with our keys and our existing js code, it's not going to help us much.

 

Thanks again for all your assistance.

 

Greg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

I noticed in tab 1 you hit https://documentcloud.adobe.com/view-sdk/main.js. In example 2 you use https://documentservices.adobe.com/view-sdk/main.js. See the different url? So when we launched the "Modern Viewer", we also (a bit later I believe) released a new URL for the Embed API as some enterprises block documentcloud. So try the key with documentcloud. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2022 Oct 10, 2022

Copy link to clipboard

Copied

Same issue here. Can we get a reply on this thread ASAP as we have client deliverables that are at risk because of this bug. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2022 Oct 10, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

@Raymond Camden 

If it helps - I agree with @gregabyte here. I also encounter the issue when highlighting text that are longer than a few words, so I am speculating when the quadPoints contain 20+ items.

 

It could also help if we are provided with a workaround in the meantime? Like maybe an older version that is stable?

 

In my own application I just show a pop-up "Something went wrong" when the quadPoints are too big and I do not save that problematic annotation. That way at least the older/other annotations will show if the page is refreshed.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

I'm trying our online demo, https://documentcloud.adobe.com/view-sdk-demo/index.html#/view/FULL_WINDOW/Bodea%20Brochure.pdf, and I can select a lot of text w/o seeing the issue. Are you able to reproduce the error there? If so, post a screen shot of how you marked it up and I'll try to replicate. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

Hey @Raymond Camden. If you re-read my steps to replicate, you can't do that in the online demo. The act of highlighting items and commenting DOES work. It even saves these comments no problem. The issue is when you try to load an existing PDF with highlighted comments on the 2nd page or further in the PDF. That is when it fails to load.

If there is a way to create comments, save the comments, and then go back to the PDF and have those past comments appear in the online demo then you will see this issue occurring and the console error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

I'm not able to replicate that. Can you share the PDF you used? I can then try uploading it to the online demo.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

You can try it using this PDF: https://www.dropbox.com/t/QBG7zhlbkR2aBSeH

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

Did you upload the right PDF? I see no comments in this PDF. It loads just fine in the Embed demo.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

Try this one with multiple comments in it: https://www.dropbox.com/t/TQlyncXUmlTGO5ue

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

@Raymond Camden the problem is that we are not comparing apples to apples. The online demo allows you to load a PDF with comments embedded directly into the PDF -- that DOES work. What we are trying to do is:

  1. Use the PDF markup tool.
  2. Make comments and markup in the PDF using your markup tool.
  3. Save those comments within the tool itself and into our database.
  4. Close the PDF markup tool.
  5. Reload the PDF markup tool and load in the past comments into the PDF from our database to show all past markups -- the PDF itself is "clean" and has no embedded markups, all markups are being drawn dynamically within the tool during the reload.
  6. This reload works correctly, unless you are using the highlight tool or underline tool.
  7. That is the issue, the online demo doesn't allow us the ability to do the steps online above. It allows us to make comments (which works), load a PDF with embedded comments in it (which works), but doesn't allow us to save and then reload a PDF with comments within the tool itself (which doesn't work).

 

Does that make sense?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

Ok, so to be clear, this is what I understood the original problem to be. I thought you were descriibng a NEW problem. This thread has gotten a bit busy today. 🙂 So yes, as you describe is what I've confirmed the issue with adding annotations to a PDF via the Embed and it failing. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

Hi @Raymond Camden 

I can confirm that this is the actual problem.

It works fine during Live editing/annotating. But when you refresh the page this error pops up. Hence why I said the error occurs here: 

annotationManager.addAnnotations(annotations);

So if you create an online demo that has a "long highlight annotation" already in the annotations object, then you will be able to replicate the error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 11, 2022 Oct 11, 2022

Copy link to clipboard

Copied

Gotcha. Again,. I thought some folks here were bringing up a *new* issue. I mean new to the original one raised here, which we've confirmed internally.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

@Raymond Camden Hi again, just checking in to see if there's any update on this. Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 13, 2022 Oct 13, 2022

Copy link to clipboard

Copied

Not yet. It's definitely known by Engineering and I've made sure they know the amount of folks running into this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2022 Oct 10, 2022

Copy link to clipboard

Copied

Hi Raymond,

 

We are also experiencing this issue with the embed API also. We get the same exact error: "Annotation selector is not valid for given xxxx". Text comments don't seem to be an issue, but as soon as we highlight or underline something (and it's more than a few words), the error appears.

 

We are using this on a high priority project and need this functionality to get fixed. I know you have no idea when it will be fixed, but are there perhaps any workarounds you can provide in the meantime? Even if we can disable the highlight or underline buttons until this is fixed, that would be something.

 

Thanks,

 

Greg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 10, 2022 Oct 10, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 10, 2022 Oct 10, 2022

Copy link to clipboard

Copied

Adobe PDF Embed API.pngHi @Raymond Camden, we have the Adobe PDF Embed API in one of our SaaS platforms. We tested the functionality back on September 26, 27, 28 and all comments and mark-ups (including highlighting and drawings) were saving properly. However, this is no longer worker now

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 10, 2022 Oct 10, 2022

Copy link to clipboard

Copied

To all in this thread, I am updating the reported bug with the additional folks reporting issues. That's all I can do at the moment.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Oct 10, 2022 Oct 10, 2022

Copy link to clipboard

Copied

@Raymond Camden thank you so much for your quick response! We look forward to any further help you can provide. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 19, 2022 Oct 19, 2022

Copy link to clipboard

Copied

Following this one, any updates @Raymond Camden 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 19, 2022 Oct 19, 2022

Copy link to clipboard

Copied

No update from engineering yet, sorry.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 19, 2022 Oct 19, 2022

Copy link to clipboard

Copied

Do you have a ball park idea when engineering would get to it? is it weeks or months scale? Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources