diff --git a/EnvelopeGenerator.Web/wwwroot/js/annotation.js b/EnvelopeGenerator.Web/wwwroot/js/annotation.js index 658feaba..703830e7 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/annotation.js +++ b/EnvelopeGenerator.Web/wwwroot/js/annotation.js @@ -1,4 +1,10 @@ -async function createAnnotations(document, envelopeId, receiverId) { +let __elementIndex = 0; + +function generateId(envelopeId, receiverId, annotationType) { + return `${envelopeId}#${receiverId}#${__elementIndex++}#${annotationType}`; +} + +async function createAnnotations(document, envelopeId, receiverId) { const signatures = []; for (let element of document.elements) { @@ -6,19 +12,13 @@ const page = element.page - 1 } - let elementIndex = 0; - - function generateId(annotationType) { - return `${envelopeId}#${receiverId}#${elementIndex++}#${annotationType}`; - } - for (let element of document.elements) { const annotParams = await getAnnotationParams(element.left, element.top); const page = element.page - 1 //#region signatures const annotation = new PSPDFKit.Annotations.WidgetAnnotation({ - id: generateId('signature'), + id: generateId(envelopeId, receiverId, 'signature'), pageIndex: page, formFieldName: id, backgroundColor: PSPDFKit.Color.LIGHT_YELLOW, @@ -34,7 +34,7 @@ //#region position const annotation_position = new PSPDFKit.Annotations.WidgetAnnotation({ - id: generateId('position'), + id: generateId(envelopeId, receiverId, 'position'), pageIndex: page, formFieldName: id_position, backgroundColor: PSPDFKit.Color.DarkBlue, @@ -53,7 +53,7 @@ //#region city const annotation_city = new PSPDFKit.Annotations.WidgetAnnotation({ - id: generateId('city'), + id: generateId(envelopeId, receiverId, 'city'), pageIndex: page, formFieldName: id_city, backgroundColor: PSPDFKit.Color.DarkBlue, @@ -72,7 +72,7 @@ //#region date const annotation_date = new PSPDFKit.Annotations.WidgetAnnotation({ - id: generateId('date'), + id: generateId(envelopeId, receiverId, 'date'), pageIndex: page, formFieldName: id_date, backgroundColor: PSPDFKit.Color.DarkBlue, @@ -99,7 +99,7 @@ //#region date label const annotation_date_label = new PSPDFKit.Annotations.WidgetAnnotation({ - id: generateId('date_label'), + id: generateId(envelopeId, receiverId, 'date_label'), pageIndex: page, formFieldName: id_date_label, blendMode: 'normal', @@ -121,7 +121,7 @@ //#region city label const annotation_city_label = new PSPDFKit.Annotations.WidgetAnnotation({ - id: generateId('city_label'), + id: generateId(envelopeId, receiverId, 'city_label'), pageIndex: page, formFieldName: id_city_label, blendMode: 'normal', @@ -143,7 +143,7 @@ //#region position label const annotation_position_label = new PSPDFKit.Annotations.WidgetAnnotation({ - id: generateId('position_label'), + id: generateId(envelopeId, receiverId, 'position_label'), pageIndex: page, formFieldName: id_position_label, blendMode: 'normal',