Annotation Uniques IDs not same when page is refreshed

Community Beginner ,
Jul 20, 2022 Jul 20, 2022

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?

Views

59

Likes

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 Expert ,
Jul 21, 2022 Jul 21, 2022

Copy link to clipboard

Copied

Are the annotations coming from the source PDF or were they added using Embed API?

Likes

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 ,
Jul 24, 2022 Jul 24, 2022

Copy link to clipboard

Copied

The annotations are added by the users when they load the pdf in the browser.

Likes

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 Expert ,
Jul 25, 2022 Jul 25, 2022

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?

Likes

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 ,
Jul 28, 2022 Jul 28, 2022

Copy link to clipboard

Copied

LATEST

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,
			{}
		);
	}

 

Likes

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