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 Using
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared ReadOnly FormFieldIndex As ImmutableDictionary(Of String, Integer) =
|
Public Shared ReadOnly FormFieldIndex As New Dictionary(Of String, Integer) From {
|
||||||
New Dictionary(Of String, Integer) From {
|
{FieldNames.NoName, 0},
|
||||||
{Nothing, 0},
|
{"signature", 1},
|
||||||
{"signature", 0},
|
{"position", 2},
|
||||||
{"date", 1},
|
|
||||||
{"date_label", 2},
|
|
||||||
{"city", 3},
|
{"city", 3},
|
||||||
{"city_label", 4},
|
{"date", 4}
|
||||||
{"position", 5},
|
}
|
||||||
{"position_label", 6}
|
|
||||||
}.ToImmutableDictionary()
|
|
||||||
|
|
||||||
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)
|
||||||
@ -88,7 +84,6 @@ Namespace Jobs.FinalizeDocument
|
|||||||
Dim yPosOfSigAnnot = oAnnotationData.annotations.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7
|
Dim yPosOfSigAnnot = oAnnotationData.annotations.ElementAt(2).bbox.ElementAt(1) - 71.84002685546875 + 7
|
||||||
Dim isSeal = True 'First element is signature seal
|
Dim isSeal = True 'First element is signature seal
|
||||||
|
|
||||||
Dim formFieldIndex = 0
|
|
||||||
For Each oAnnotation In oAnnotationData.annotations
|
For Each oAnnotation In oAnnotationData.annotations
|
||||||
Logger.Debug("Adding AnnotationID: " + oAnnotation.id)
|
Logger.Debug("Adding AnnotationID: " + oAnnotation.id)
|
||||||
|
|
||||||
@ -110,8 +105,7 @@ Namespace Jobs.FinalizeDocument
|
|||||||
'Add form field values
|
'Add form field values
|
||||||
Dim formFieldValue = oAnnotationData.formFieldValues.FirstOrDefault(Function(fv) fv.name = oAnnotation.id)
|
Dim formFieldValue = oAnnotationData.formFieldValues.FirstOrDefault(Function(fv) fv.name = oAnnotation.id)
|
||||||
If formFieldValue IsNot Nothing AndAlso Not _pdfBurnerParams.IgnoredLabels.Contains(formFieldValue.value) Then
|
If formFieldValue IsNot Nothing AndAlso Not _pdfBurnerParams.IgnoredLabels.Contains(formFieldValue.value) Then
|
||||||
AddFormFieldValue(oAnnotation, formFieldValue, formFieldIndex)
|
AddFormFieldValue(oAnnotation, formFieldValue)
|
||||||
formFieldIndex += 1
|
|
||||||
End If
|
End If
|
||||||
Exit Select
|
Exit Select
|
||||||
End Select
|
End Select
|
||||||
@ -152,12 +146,15 @@ Namespace Jobs.FinalizeDocument
|
|||||||
Next
|
Next
|
||||||
End Function
|
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
|
' Convert pixels to Inches
|
||||||
Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
|
Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
|
||||||
|
|
||||||
Dim oX = oBounds.Item(0)
|
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 oWidth = oBounds.Item(2)
|
||||||
Dim oHeight = oBounds.Item(3)
|
Dim oHeight = oBounds.Item(3)
|
||||||
|
|
||||||
@ -220,7 +217,7 @@ Namespace Jobs.FinalizeDocument
|
|||||||
|
|
||||||
Public index As Integer = Nothing
|
Public index As Integer = Nothing
|
||||||
|
|
||||||
Public fieldName As String = Nothing
|
Public fieldName As String = FieldNames.NoName
|
||||||
|
|
||||||
Public hasStructuredID As Boolean = False
|
Public hasStructuredID As Boolean = False
|
||||||
|
|
||||||
@ -286,6 +283,10 @@ Namespace Jobs.FinalizeDocument
|
|||||||
Public Property strokeColor As String
|
Public Property strokeColor As String
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
Public Class FieldNames
|
||||||
|
Public Shared ReadOnly NoName As String = Guid.NewGuid().ToString()
|
||||||
|
End Class
|
||||||
|
|
||||||
Friend Class Lines
|
Friend Class Lines
|
||||||
Public Property points As List(Of List(Of List(Of Single)))
|
Public Property points As List(Of List(Of List(Of Single)))
|
||||||
End Class
|
End Class
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user