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) Private Sub AddInstantJSONAnnotationToPDF(pInstantJSON As String)
Dim oAnnotationData = JsonConvert.DeserializeObject(Of AnnotationData)(pInstantJSON) Dim oAnnotationData = JsonConvert.DeserializeObject(Of AnnotationData)(pInstantJSON)
oAnnotationData.annotations.Reverse()
Dim yPosOfSigAnnot = oAnnotationData.annotations.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7 For Each annots In oAnnotationData.AnnotationsByReceiver
Dim isSeal = True 'First element is signature seal annots.Reverse()
Dim formFieldIndex = 0 Dim yPosOfSigAnnot = annots.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7
For Each oAnnotation In oAnnotationData.annotations Dim isSeal = True 'First element is signature seal
Logger.Debug("Adding AnnotationID: " + oAnnotation.id)
Select Case oAnnotation.type Dim formFieldIndex = 0
Case ANNOTATION_TYPE_IMAGE For Each oAnnotation In annots
Logger.Debug("Adding AnnotationID: " + oAnnotation.id)
If (isSeal) Then Select Case oAnnotation.type
oAnnotation.bbox.Item(1) = yPosOfSigAnnot Case ANNOTATION_TYPE_IMAGE
End If
AddImageAnnotation(oAnnotation, oAnnotationData.attachments) If (isSeal) Then
Exit Select oAnnotation.bbox.Item(1) = yPosOfSigAnnot
End If
Case ANNOTATION_TYPE_INK AddImageAnnotation(oAnnotation, oAnnotationData.attachments)
AddInkAnnotation(oAnnotation) Exit Select
Exit Select
Case ANNOTATION_TYPE_WIDGET Case ANNOTATION_TYPE_INK
'Add form field values AddInkAnnotation(oAnnotation)
Dim formFieldValue = oAnnotationData.formFieldValues.FirstOrDefault(Function(fv) fv.name = oAnnotation.id) Exit Select
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 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 Next
End Sub End Sub
Private Function AddImageAnnotation(pAnnotation As Annotation, pAttachments As Dictionary(Of String, Attachment)) As Void Private Function AddImageAnnotation(pAnnotation As Annotation, pAttachments As Dictionary(Of String, Attachment)) As Void
@ -187,7 +191,7 @@ Namespace Jobs.FinalizeDocument
Friend Class Annotation Friend Class Annotation
Private _id As Integer Private _id As String
Public envelopeId As Integer Public envelopeId As Integer