Accessing the annotations on Save button or without opening the pdf document
I want to access/get the annotations upon the save button click. As from the code in adobe pdf embed api sample here on github, I am able to access/ console.log() the annotations on document load but in case a user adds more annotations to the loaded document and clicks the save button, I need to access those annotations and save it somewhere in external json or database.
Here is my react code
useEffect(() => {
const viewSDKClient = new ViewSDKClient();
viewSDKClient.ready().then(() => {
/* Invoke file preview */
/* By default the embed mode will be Full Window */
const previewFilePromise = viewSDKClient.previewFile("pdf-div", { enableAnnotationAPIs: true, includePDFAnnotations: true }, fileUrl);
previewFilePromise
.then((adobeViewer) => {
adobeViewer.getAnnotationManager()
.then(annotationManager => {
annotationManager.getAnnotations()
.then(result => {
console.log("GET all annotations", result);
})
.catch(e => {
console.log(e);
});
})
.catch(e => {
console.log(e);
});
})
.catch(e => {
console.log(e);
});
//TODO: access the annotations inside the saveapi handler
viewSDKClient.registerSaveApiHandler();
viewSDKClient.registerGetUserProfileApiHandler();
});
}, []);Please let me know in case more info is required from my end.
