refactor(pdfburner): simplify form field handling and improve default field naming
- Replaced ImmutableDictionary-based FormFieldIndex with a simpler Dictionary - Updated form field ordering to: NoName, signature, position, city, date - Removed manual formFieldIndex counter, now using dictionary lookup by fieldName - Introduced FieldNames class with NoName constant (guid-based) for unnamed fields - Defaulted Annotation.fieldName to FieldNames.NoName instead of Nothing
This commit is contained in:
parent
ce7ca39c39
commit
1f745ae79c
@ -69,17 +69,13 @@ Namespace Jobs.FinalizeDocument
|
||||
End Using
|
||||
End Function
|
||||
|
||||
Public Shared ReadOnly FormFieldIndex As ImmutableDictionary(Of String, Integer) =
|
||||
New Dictionary(Of String, Integer) From {
|
||||
{Nothing, 0},
|
||||
{"signature", 0},
|
||||
{"date", 1},
|
||||
{"date_label", 2},
|
||||
Public Shared ReadOnly FormFieldIndex As New Dictionary(Of String, Integer) From {
|
||||
{FieldNames.NoName, 0},
|
||||
{"signature", 1},
|
||||
{"position", 2},
|
||||
{"city", 3},
|
||||
{"city_label", 4},
|
||||
{"position", 5},
|
||||
{"position_label", 6}
|
||||
}.ToImmutableDictionary()
|
||||
{"date", 4}
|
||||
}
|
||||
|
||||
Private Sub AddInstantJSONAnnotationToPDF(pInstantJSON As String)
|
||||
Dim oAnnotationData = JsonConvert.DeserializeObject(Of AnnotationData)(pInstantJSON)
|
||||
@ -88,7 +84,6 @@ Namespace Jobs.FinalizeDocument
|
||||
Dim yPosOfSigAnnot = oAnnotationData.annotations.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7
|
||||
Dim isSeal = True 'First element is signature seal
|
||||
|
||||
Dim formFieldIndex = 0
|
||||
For Each oAnnotation In oAnnotationData.annotations
|
||||
Logger.Debug("Adding AnnotationID: " + oAnnotation.id)
|
||||
|
||||
@ -110,8 +105,7 @@ Namespace Jobs.FinalizeDocument
|
||||
'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
|
||||
AddFormFieldValue(oAnnotation, formFieldValue)
|
||||
End If
|
||||
Exit Select
|
||||
End Select
|
||||
@ -152,12 +146,15 @@ Namespace Jobs.FinalizeDocument
|
||||
Next
|
||||
End Function
|
||||
|
||||
Private Function AddFormFieldValue(pAnnotation As Annotation, formFieldValue As FormFieldValue, index As Integer) As Void
|
||||
Private Function AddFormFieldValue(pAnnotation As Annotation, formFieldValue As FormFieldValue) As Void
|
||||
|
||||
Dim index As Integer = FormFieldIndex(pAnnotation.fieldName)
|
||||
|
||||
' Convert pixels to Inches
|
||||
Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
|
||||
|
||||
Dim oX = oBounds.Item(0)
|
||||
Dim oY = oBounds.Item(1) + _pdfBurnerParams.YOffset * index + _pdfBurnerParams.TopMargin
|
||||
Dim oY = oBounds.Item(1) + _pdfBurnerParams.YOffset * Index + _pdfBurnerParams.TopMargin
|
||||
Dim oWidth = oBounds.Item(2)
|
||||
Dim oHeight = oBounds.Item(3)
|
||||
|
||||
@ -220,7 +217,7 @@ Namespace Jobs.FinalizeDocument
|
||||
|
||||
Public index As Integer = Nothing
|
||||
|
||||
Public fieldName As String = Nothing
|
||||
Public fieldName As String = FieldNames.NoName
|
||||
|
||||
Public hasStructuredID As Boolean = False
|
||||
|
||||
@ -286,6 +283,10 @@ Namespace Jobs.FinalizeDocument
|
||||
Public Property strokeColor As String
|
||||
End Class
|
||||
|
||||
Public Class FieldNames
|
||||
Public Shared ReadOnly NoName As String = Guid.NewGuid().ToString()
|
||||
End Class
|
||||
|
||||
Friend Class Lines
|
||||
Public Property points As List(Of List(Of List(Of Single)))
|
||||
End Class
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user