Hello kkim,
Thanks for the response, I have add the complete code for your reference.
I have also notice one thing that , If i execute this part of my code.
const AttachedDocsItems = [];
let Annotationsmark = [];
let fileList = [];
let core = '';
let percentageChangeModalCreated = false;
const rotationChanges = [];
let isComparePopupOpen = false;
let userID = '';
let isLayover = false;
let isSideBySide = false;
let isRotatingPages = false;
let isDocumentLoading = false;
let isImageStampPanelOpen = false;
let isDropListenerBound = false;
let dropInProgress = false;
let isRealtimeEnabled = true;
let currentPdfFileId = '';
let userAction = '';
let originalContentItemId = '';
let isImporting = false;
let selectedDepartments = new Set();
let saveStamp = false;
let caseTags = [];
let caseTagCount = [];
let currentSettings = {
offComments: false,
offStamps: false,
offAnnotations: false,
offPictures: false,
onlyMyComments: false,
};
let url = '';
let lastStamp = null;
let connection = '';
let currentGroup = '';
let imageData = [];
let defaultComparaLayout = '';
let hideCADState = false;
const Apryse = {
viewerId: '',
pdffilepath: '',
licenseKey: '',
userId: '',
annotationList: '',
userName: '',
annotationsData: '',
stampData: '',
rotationPage: '',
rotationAngle: '',
saveIcon: '',
viewSettingIcon: '',
compareIcon: '',
title: '',
bold: false,
color: '',
font: '',
italic: false,
isImageAddedFromPanel: false,
underline: false,
annotId: '',
strikeout: false,
textColor: '',
stampUserName: '',
isUserNameChecked: false,
isDateChecked: false,
subtitle: '',
isTimeChecked: false,
dateFormat: '',
turnOffComments: false,
turnOffStamps: false,
turnOffAnnotations: false,
turnOffPictures: false,
turnOffForm: true,
turnOffFillAndSign: true,
turnOffSignature: true,
isAdmin: true,
signatureUrl: '',
isForntEndDoc: false,
permissions: [],
files: [],
departments: [],
compareDefaultLayout: '',
initilize: function () {
$('.common-loading-spinner-text').text('Please do not close your browser or press the back button until the document has fully loaded.');
$('.common-loading').show();
WebViewer.Iframe({
path: '/GovBuilt.PlanReview/webviewer',
licenseKey: Apryse.licenseKey,
initialDoc: !Apryse.isForntEndDoc ? Apryse.pdffilepath : null,
loadSpinner: false,
annotationUser: this.userId,
compareDefaultLayout: Apryse.compareDefaultLayout,
permissions: Apryse.permissions,
fullAPI: true,
UI: 'Modular',
css: '/GovBuilt.PlanReview/css/viewer.min.css',
}, document.getElementById(Apryse.viewerId))
.then((instance) => {
window.webViewerInstance = instance;
core = instance.Core;
const { documentViewer, annotationManager, Annotations } = instance.Core;
const { Feature } = instance.UI;
const { Color } = Annotations;
const { PDFNet, Tools } = instance.Core;
const UIEvents = instance.UI.Events;
The issue is not reproduce.
Apryse.js (124.4 KB)
After few investigation I found the issue is then line of code
connection = new signalR.HubConnectionBuilder()
.withUrl(`/planReviewAnnotationHub?pdfFileId=${currentPdfFileId}`)
.withAutomaticReconnect()
.build();
connection.start().then(() => {
});
connection.on("ReceiveAnnotation", function (annotationData, action) {
if (!isRealtimeEnabled) {
isRealtimeEnabled = true;
}
isImporting = true;
instance.UI.enableElement('customCollaborationButton');
if (action === 'delete') {
const deletedAnnotIds = PartialApryse.GetAnnotationIdFromXFDF(annotationData);
const existingAnnotations = annotationManager.getAnnotationsList();
deletedAnnotIds.forEach(id => {
const toDeleteAnnot = existingAnnotations.find(annot => annot.nj === id);
if (toDeleteAnnot) {
annotationManager.deleteAnnotation(toDeleteAnnot);
}
});
} else {
annotationManager.importAnnotations(annotationData).then(() => {
isImporting = false;
});
}
isImporting = false;
instance.Core.documentViewer.refreshAll();
instance.Core.documentViewer.updateView();
});
connection.on("ReceiveRealtimeToggle", function (newState) {
isRealtimeEnabled = newState;
});
connection.on("ReceiveUserCountChanged", function (userCount) {
if (userCount > 1) {
instance.UI.enableElement(['turnOffAutoSync']);
instance.UI.disableElement(['turnOnAutoSync']);
} else {
instance.UI.disableElement(['turnOffAutoSync']);
}
});
annotationManager.addEventListener('annotationChanged', function (annotations, action) {
if (isImporting) return;
if (['add', 'modify', 'delete'].includes(action)) {
annotationManager.exportAnnotations({ annotationList: annotations, action: action }).then(xfdfString => {
connection.invoke("SendAnnotationAsync", currentPdfFileId, xfdfString, action);
});
}
});
annotationManager.addEventListener('annotationChanged', handleAnnotationChanged);
the issue is in this. When i uncomment it user not able to add other annotation over rectangular area annotation. If I comment this then user able to add other annotation over rectangular area annotation
When i uncomment it user not able to add other annotation over rectangular area annotation. If I comment this then user able to add other annotation over rectangular area annotation
const xfdf = await annotationManager.exportAnnotations();
issue is with this line
annotationManager.addEventListener('annotationChanged', async (annotations, action, info) => {
if (isImporting || isDocumentLoading) return;
const measurementTools = [
'AnnotationCreateAreaMeasurement',
'AnnotationCreateEllipseAreaMeasurement',
'AnnotationCreateRectangularAreaMeasurement',
'AnnotationCreateCountMeasurement'
];
const isMeasurement = annotations.some(a => measurementTools.includes(a.ToolName));
if (isMeasurement) {
if (action === 'add' || action === 'modify' || action === 'delete') {
const xfdf = await annotationManager.exportAnnotations();
annotations.forEach(a => {
if (measurementTools.includes(a.ToolName)) {
PartialApryse.ProcessAnnotation(a, xfdf, action);
}
});
PartialApryse.SaveDocumentAnnotations();
}
return;
}
if (['add', 'modify', 'delete'].includes(action)) {
const xfdf = await annotationManager.exportAnnotations({
annotationList: annotations,
action
});
connection.invoke("SendAnnotationAsync", currentPdfFileId, xfdf, action);
}
const stamps = annotations.filter(a => a.ToolName === "AnnotationCreateRubberStamp");
if (stamps.length > 0 && saveStamp && action !== 'delete') {
const xfdfStrings = await annotationManager.exportAnnotationCommand();
stamps.forEach(a => PartialApryse.ProcessAnnotation(a, xfdfStrings, action));
PartialApryse.SaveDocumentAnnotations();
}
});