update to use annotations-by-receiver for iteration

This commit is contained in:
tekh 2025-10-07 22:16:52 +02:00
parent 74f444a8d6
commit 39936792aa

View File

@ -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