From 39936792aac3a8439a333262b1bf6d5e474a1e31 Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 7 Oct 2025 22:16:52 +0200 Subject: [PATCH] update to use annotations-by-receiver for iteration --- .../Jobs/FinalizeDocument/PDFBurner.vb | 58 ++++++++++--------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb index 46db6701..eeb5dee6 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb @@ -70,41 +70,45 @@ Namespace Jobs.FinalizeDocument Private Sub AddInstantJSONAnnotationToPDF(pInstantJSON As String) Dim oAnnotationData = JsonConvert.DeserializeObject(Of AnnotationData)(pInstantJSON) - oAnnotationData.annotations.Reverse() - Dim yPosOfSigAnnot = oAnnotationData.annotations.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7 - Dim isSeal = True 'First element is signature seal + For Each annots In oAnnotationData.AnnotationsByReceiver + annots.Reverse() - Dim formFieldIndex = 0 - For Each oAnnotation In oAnnotationData.annotations - Logger.Debug("Adding AnnotationID: " + oAnnotation.id) + Dim yPosOfSigAnnot = annots.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7 + Dim isSeal = True 'First element is signature seal - Select Case oAnnotation.type - Case ANNOTATION_TYPE_IMAGE + Dim formFieldIndex = 0 + For Each oAnnotation In annots + Logger.Debug("Adding AnnotationID: " + oAnnotation.id) - If (isSeal) Then - oAnnotation.bbox.Item(1) = yPosOfSigAnnot - End If + Select Case oAnnotation.type + Case ANNOTATION_TYPE_IMAGE - AddImageAnnotation(oAnnotation, oAnnotationData.attachments) - Exit Select + If (isSeal) Then + oAnnotation.bbox.Item(1) = yPosOfSigAnnot + End If - Case ANNOTATION_TYPE_INK - AddInkAnnotation(oAnnotation) - Exit Select + AddImageAnnotation(oAnnotation, oAnnotationData.attachments) + Exit Select - Case ANNOTATION_TYPE_WIDGET - 'Add form field values - Dim formFieldValue = oAnnotationData.formFieldValues.FirstOrDefault(Function(fv) fv.name = oAnnotation.id) - If formFieldValue IsNot Nothing AndAlso Not _pdfBurnerParams.IgnoredLabels.Contains(formFieldValue.value) Then - AddFormFieldValue(oAnnotation, formFieldValue, formFieldIndex) - formFieldIndex += 1 - End If - Exit Select - End Select + Case ANNOTATION_TYPE_INK + AddInkAnnotation(oAnnotation) + Exit Select - isSeal = False + Case ANNOTATION_TYPE_WIDGET + 'Add form field values + Dim formFieldValue = oAnnotationData.formFieldValues.FirstOrDefault(Function(fv) fv.name = oAnnotation.id) + If formFieldValue IsNot Nothing AndAlso Not _pdfBurnerParams.IgnoredLabels.Contains(formFieldValue.value) Then + AddFormFieldValue(oAnnotation, formFieldValue, formFieldIndex) + formFieldIndex += 1 + End If + Exit Select + End Select + + isSeal = False + Next Next + End Sub Private Function AddImageAnnotation(pAnnotation As Annotation, pAttachments As Dictionary(Of String, Attachment)) As Void @@ -187,7 +191,7 @@ Namespace Jobs.FinalizeDocument Friend Class Annotation - Private _id As Integer + Private _id As String Public envelopeId As Integer