Copy link to clipboard
Copied
There appears to be an issue with Note Annotations boundingBox not being updated. When I try to use the updateAnnotations method with an Note where the only change is the bounding box an error is thrown saying there is nothing to update.
In the docs it specifically says this is possible for note annotations, but I only get the error message.
https://developer.adobe.com/document-services/docs/overview/pdf-embed-api/howtos_comments/#updateann...
I can provide more information if necesarry. Please let me know how to resolve this.
Appending a space to the bodyValue fixed the issue I had. It appears bounding boxes can only be updated if the text is modified. Note movement is now syncing correctly and the bounding box check is working correctly. Thanks for the help @Joel_Geraci !
Copy link to clipboard
Copied
Can you show your code?
Copy link to clipboard
Copied
_checkAnnotationBoundingBox (annotation) {
console.log("Checking Annotation Bounding Box");
console.log(annotation);
//copy annotation
let annotationCopy = JSON.parse(JSON.stringify(annotation));
if (annotation.motivation === "commenting") {
const target = annotation.target;
const selector = target.selector;
if (selector.subtype === "note") {
const boundingBox = selector.boundingBox;
const x1 = boundingBox[0];
const y1 = boundingBox[1];
const x2 = boundingBox[2];
const y2 = boundingBox[3];
const width = x2 - x1;
const height = y2 - y1;
let annotationChanged = false;
if (width !== DEFAULT_COMMENT_SIZE) {
annotationChanged = true;
annotationCopy.target.selector.boundingBox[2] = x1 + DEFAULT_COMMENT_SIZE;
}
if (height !== DEFAULT_COMMENT_SIZE) {
annotationCopy.target.selector.boundingBox[3] = y1 + DEFAULT_COMMENT_SIZE;
annotationChanged = true;
}
if (annotationChanged) {
console.log("Updating Annotation Bounding Box");
console.log(annotationCopy);
this.adobeViewer.getAnnotationManager().then(annotationManager => {
annotationManager.updateAnnotation(annotationCopy).catch((error) => {
console.error("Failed to Update Annotation");
console.error(error);
});
});
}
}
}
return annotation;
}
The client I am working for wanted all the Note bubbles to be uniforms sizes when downloaded and read in another pdf viewer. (Sometimes Note Annotations have rectangular instead of square bounding boxes for some reason) So I tried to run this code so that one annotation_added event it would check the size and update, but it throws an error saying there are no updatable fields. I can grab the exact error message later today if needed.
Side note: I have some syncing logic for updates on different clients and when a note is moved on one client it doesnot move on the other clients which I believe is related.
Copy link to clipboard
Copied
Ok - This is going to sound odd try updating the text as well. Just add a space to the end or something. Originally, you could only update the text.
Copy link to clipboard
Copied
Thanks, I'll try that and let you know if that works when I have time to test it.
Copy link to clipboard
Copied
Appending a space to the bodyValue fixed the issue I had. It appears bounding boxes can only be updated if the text is modified. Note movement is now syncing correctly and the bounding box check is working correctly. Thanks for the help @Joel_Geraci !