Annotation Uniques IDs not same when page is refreshed
Copy link to clipboard
Copied
I am using the react repo on Github. I noticed that the annotation unique IDs do not stay same when the PDF is loaded/reloaded. Could you please advise if somehow these IDs could be made the same across different loads?
Copy link to clipboard
Copied
Are the annotations coming from the source PDF or were they added using Embed API?
Copy link to clipboard
Copied
The annotations are added by the users when they load the pdf in the browser.
Copy link to clipboard
Copied
The annotations wouldn't persist between loading/reloading the PDF in the browser. Are you saying that they add the annotations, save the PDF locally, and then reload it from local? If not, how are you making the annotations persistent?
Copy link to clipboard
Copied
The pdf documents are uploaded by users to a server. The users can then view the list of these uploaded files in their browser and view these files. Users can then open these documents and save their annotations to the document. Upon clicking the save button in the pdf, the files are saved back to the server. So the added annotations are saved as part of the pdf.
Here is the code for my customized registerSaveApiHandler in the viewSDKClient.js
registerSaveApiHandler() {
const saveApiHandler = (metaData, content, options) => {
const uint8Array = new Uint8Array(content);
const blob = new Blob([uint8Array], { type: 'application/pdf' });
let formData = new FormData();
let pdfFilename = metaData.fileName;
formData.append('uploadedFile', blob, pdfFilename);
formData.append('fileId', this.fileDetails.Id);
formData.append('userId', this.user.id);
formData.append('annotations', JSON.stringify(this.annots));
const fileSaveUrl = process.env.REACT_APP_PDF_FILE_SAVE_ENDPOINT;
fetch(fileSaveUrl, {
method: 'POST',
body: formData
}).then((response) => {
if (response.status === 200) {
alert('file saved');
} else {
alert('internal error');
window.location.reload();
}
}).catch();
return new Promise(function (resolve, reject) {
var response = {
code: window.AdobeDC.View.Enum.ApiResponseCode.SUCCESS,
data: {
metaData: Object.assign(metaData, { updatedAt: new Date().getTime() })
},
};
resolve(response);
});
};
this.adobeDCView.registerCallback(
window.AdobeDC.View.Enum.CallbackType.SAVE_API,
saveApiHandler,
{}
);
}

