From 320b2ecc77b1b2209e222655eb31e273485d1b88 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 6 Oct 2025 17:08:44 +0200 Subject: [PATCH] refactor(AnnotationData): add SignatureAnnotations-getter method to split signatures --- .../Jobs/FinalizeDocument/PDFBurner.vb | 74 +++++++++++-------- 1 file changed, 45 insertions(+), 29 deletions(-) diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb index e24ee4b3..f5f3cc6d 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb @@ -76,35 +76,35 @@ Namespace Jobs.FinalizeDocument Dim isSeal = True 'First element is signature seal Dim formFieldIndex = 0 - For Each oAnnotation In oAnnotationData.annotations - Logger.Debug("Adding AnnotationID: " + oAnnotation.id) - - Select Case oAnnotation.type - Case ANNOTATION_TYPE_IMAGE - - If (isSeal) Then - oAnnotation.bbox.Item(1) = yPosOfSigAnnot - End If - - AddImageAnnotation(oAnnotation, oAnnotationData.attachments) - Exit Select - - Case ANNOTATION_TYPE_INK - AddInkAnnotation(oAnnotation) - 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 - - isSeal = False - Next + For Each oAnnotation In oAnnotationData.annotations + Logger.Debug("Adding AnnotationID: " + oAnnotation.id) + + Select Case oAnnotation.type + Case ANNOTATION_TYPE_IMAGE + + If (isSeal) Then + oAnnotation.bbox.Item(1) = yPosOfSigAnnot + End If + + AddImageAnnotation(oAnnotation, oAnnotationData.attachments) + Exit Select + + Case ANNOTATION_TYPE_INK + AddInkAnnotation(oAnnotation) + 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 + + isSeal = False + Next End Sub Private Function AddImageAnnotation(pAnnotation As Annotation, pAttachments As Dictionary(Of String, Attachment)) As Void @@ -172,6 +172,22 @@ Namespace Jobs.FinalizeDocument Friend Class AnnotationData Public Property annotations As List(Of Annotation) + + Public ReadOnly Property SignatureAnnotations As List(Of List(Of Annotation)) + Get + Dim result As New List(Of List(Of Annotation))() + + If annotations IsNot Nothing AndAlso annotations.Count > 0 Then + For i As Integer = 0 To annotations.Count - 1 Step 6 + Dim group As List(Of Annotation) = annotations.Skip(i).Take(6).ToList() + result.Add(group) + Next + End If + + Return result + End Get + End Property + Public Property attachments As Dictionary(Of String, Attachment) Public Property formFieldValues As List(Of FormFieldValue) End Class