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>
Copy link to clipboard
Copied
@Raymond Camden Regarding your comment on here: https://community.adobe.com/t5/document-services-apis-discussions/document-annotations-not-showing/t...
Do you still need an online example? Or is this source code enough?
Kind regards
Copy link to clipboard
Copied
Yes please, if you can put something together that is complete, it would help. A CodePen would be awesome.
Copy link to clipboard
Copied
I was really hoping to get some better help from this channel. Topics that were opened after mine were answered, but mine is just being ignored. Should I have provided better information or what can I do to get some guidance?
Copy link to clipboard
Copied
Right now, forum support is done by a few different individuals, and sometimes scheduling makes it difficult to check back as quickly as possible.
Copy link to clipboard
Copied
Hi Raymond,
Sorry for the dealyed response. I set up a demo URL here: https://app.arkhetuponim.com/portal/adobe-test
Copy link to clipboard
Copied
Unfortunately, I can reproduce this error. I took your code and reduced it quite a bit. Going to report it internally.
Copy link to clipboard
Copied
Thanks for taking the time. I am glad you were able to reproduce the error 🙂
A similar error was reported about two years ago on this forum and it still has not been fixed.
I know it must be close to impossible to say, but do you have an idea of how long it can take to get this fixed?
I am just really hoping it does not fall through the cracks again...
Kind regards
Copy link to clipboard
Copied
Sorry, I've got no idea on that.
Copy link to clipboard
Copied
I am having the same issue. Annotations are not getting captured!
Copy link to clipboard
Copied
I am also experiencing the same issue, and we were able to debug and recreate this issue:
If you need additional information, please let me know, as we really need this up and working ASAP.
Copy link to clipboard
Copied
If you switch to https://documentservices.adobe.com/view-sdk/main.js, does it work right?
Copy link to clipboard
Copied
@Raymond Camden What is the difference between that URL and the one in the docs (https://documentservices.adobe.com/view-sdk/viewer.js)? I am trying the URL above and it seems to help somewhat, but I also see this error in the console which indicates this might be a pre-release:
Please advise, thanks!
Greg
Copy link to clipboard
Copied
Hi @Raymond Camden can you confirm if this is a pre-release and if so, if there are different keys available?
Copy link to clipboard
Copied
main.js is the OLD PDF Embed plugin, which was replaced with the Modern viewer, see https://developer.adobe.com/document-services/docs/overview/pdf-embed-api/modernviewer/. It is not a prerelease, but the previous version. I'm trying to help engineering determine if the switch to the modern viewer caused the issue. I was pretty sure it was, but this confirms it.
Copy link to clipboard
Copied
We are also getting the error "This application domain (https://corceptcp.uat.cm.skyscraperstudios.com) is not authorized to use the provided PDF Embed API Client ID." when we change to the main.js URL on our UAT environment. Are there different keys available for this version or something?
Copy link to clipboard
Copied
Um, yeah, it may have changed such that new keys can't work with the old library. Can you try making a new client id?
Copy link to clipboard
Copied
Hi @Raymond Camden , I actually had tried a new api key last night. I went to https://developer.adobe.com/console, made a new project and added PDF Embed API and got a new key:
Am I supposed to do something different to use the old version?
Copy link to clipboard
Copied
I'm confused - you said you tried it and it worked. Where is it throwing the client id error?
Copy link to clipboard
Copied
@Raymond Camden yeah, it threw that error on my local machine, then I switched back to the new one, then back to the old one and it worked (I know, very confusing). But when I tried it on our staging server (corceptcp.uat.cm.skyscraperstudios.com, which is using the new viewer at this moment), I got the key error.
Copy link to clipboard
Copied
Err... not sure what to tell you at this point. If you have a key, and it works for old, but not new, and if using old works for you for now to get around the bug you found, I'd say stick with that? Until you hear back about an update of course. Going forward the new library's going to be supported, not the older one.
Copy link to clipboard
Copied
@Raymond Camden It's the old version that the keys don't work with. Here's an example page I just setup:
http://terminus.lapcominc.com:8000/
I made a new project and added the embed api under this domain and put in the key. It still complains "This application domain (http://terminus.lapcominc.com:8000) is not authorized to use the provided PDF Embed API Client ID"
Is it not possible to get keys for the old version in case we want to fallback to this until the bug is fixed?
Thanks again!
Greg
Copy link to clipboard
Copied
So to be clear, using the old library, it never properly worked w/ the client id? I just tested making a new project, and using the old script, and it works for me. You can see the codepen here: https://codepen.io/cfjedimaster/pen/yLjGNZm
Copy link to clipboard
Copied
We need it for commenting tools for our client activity. This is just a PDF viewer. How do we add commenting tools to this?
Copy link to clipboard
Copied
So to be clear, commenting should work. The original issue involved the Annotation API, adding an annotation, and having too many quad points. It did not involve commenting. If you are seeing an issue with commenting, please make a new thread so we can properly support you.