Hinzufügen der Methode 'AddFormFieldValue' zum Hinzufügen von Datums- und Ortswerten im endgültigen Bericht.

This commit is contained in:
Developer 02 2024-06-20 11:45:03 +02:00
parent 33f4c6e489
commit 1bc43a5a77

View File

@ -15,7 +15,7 @@ Namespace Jobs.FinalizeDocument
Private Const ANNOTATION_TYPE_IMAGE = "pspdfkit/image" Private Const ANNOTATION_TYPE_IMAGE = "pspdfkit/image"
Private Const ANNOTATION_TYPE_INK = "pspdfkit/ink" Private Const ANNOTATION_TYPE_INK = "pspdfkit/ink"
Private Const ANNOTATION_TYPE_FORM = "pspdfkit/form-field-value" Private Const ANNOTATION_TYPE_WIDGET = "pspdfkit/widget"
Public Sub New(pLogConfig As LogConfig, pGDPictureLicenseKey As String) Public Sub New(pLogConfig As LogConfig, pGDPictureLicenseKey As String)
MyBase.New(pLogConfig) MyBase.New(pLogConfig)
@ -78,9 +78,12 @@ Namespace Jobs.FinalizeDocument
Case ANNOTATION_TYPE_INK Case ANNOTATION_TYPE_INK
AddInkAnnotation(oAnnotation) AddInkAnnotation(oAnnotation)
Case ANNOTATION_TYPE_FORM Case ANNOTATION_TYPE_WIDGET
AddFormAnnotation(oAnnotation) 'Add form field values
Dim formFieldValue = oAnnotationData.formFieldValues.FirstOrDefault(Function(fv) fv.name = oAnnotation.id)
If formFieldValue IsNot Nothing Then
AddFormFieldValue(oAnnotation, formFieldValue)
End If
End Select End Select
Next Next
@ -141,8 +144,31 @@ Namespace Jobs.FinalizeDocument
End Function End Function
Private Function AddFormAnnotation(pAnnotation As Annotation) As Boolean Private Function AddFormFieldValue(pAnnotation As Annotation, formFieldValue As FormFieldValue) As Boolean
Throw New Exception("Fooo") Try
' Convert pixels to Inches
Dim oBounds = pAnnotation.bbox.Select(AddressOf ToInches).ToList()
Dim oX = oBounds.Item(0)
Dim oY = oBounds.Item(1)
Dim oWidth = oBounds.Item(2)
Dim oHeight = oBounds.Item(3)
Manager.SelectPage(pAnnotation.pageIndex + 1)
' Add the text annotation
Dim ant = Manager.AddTextAnnot(oX, oY, oWidth, oHeight, formFieldValue.value)
' Set the font properties
ant.FontName = "Arial"
ant.FontSize = 8
ant.FontStyle = FontStyle.Italic
Manager.SaveAnnotationsToPage()
Return True
Catch ex As Exception
Logger.Warn("Could not add image annotation!")
Logger.Error(ex)
Return False
End Try
End Function End Function
Private Function ToPointF(pPoints As List(Of Single)) As PointF Private Function ToPointF(pPoints As List(Of Single)) As PointF
@ -185,6 +211,7 @@ Namespace Jobs.FinalizeDocument
End Class End Class
Friend Class FormFieldValue Friend Class FormFieldValue
Public Property name As String
Public Property value As String Public Property value As String
End Class End Class
End Class End Class