From 1bc43a5a7748d9dcd499b693a2a19bdcdc29887b Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 20 Jun 2024 11:45:03 +0200 Subject: [PATCH] =?UTF-8?q?Hinzuf=C3=BCgen=20der=20Methode=20'AddFormField?= =?UTF-8?q?Value'=20zum=20Hinzuf=C3=BCgen=20von=20Datums-=20und=20Ortswert?= =?UTF-8?q?en=20im=20endg=C3=BCltigen=20Bericht.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Jobs/FinalizeDocument/PDFBurner.vb | 39 ++++++++++++++++--- 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/EnvelopeGenerator.Common/Jobs/FinalizeDocument/PDFBurner.vb b/EnvelopeGenerator.Common/Jobs/FinalizeDocument/PDFBurner.vb index 15f092ce..e91dad40 100644 --- a/EnvelopeGenerator.Common/Jobs/FinalizeDocument/PDFBurner.vb +++ b/EnvelopeGenerator.Common/Jobs/FinalizeDocument/PDFBurner.vb @@ -15,7 +15,7 @@ Namespace Jobs.FinalizeDocument Private Const ANNOTATION_TYPE_IMAGE = "pspdfkit/image" 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) MyBase.New(pLogConfig) @@ -78,9 +78,12 @@ Namespace Jobs.FinalizeDocument Case ANNOTATION_TYPE_INK AddInkAnnotation(oAnnotation) - Case ANNOTATION_TYPE_FORM - AddFormAnnotation(oAnnotation) - + Case ANNOTATION_TYPE_WIDGET + '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 Next @@ -141,8 +144,31 @@ Namespace Jobs.FinalizeDocument End Function - Private Function AddFormAnnotation(pAnnotation As Annotation) As Boolean - Throw New Exception("Fooo") + Private Function AddFormFieldValue(pAnnotation As Annotation, formFieldValue As FormFieldValue) As Boolean + 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 Private Function ToPointF(pPoints As List(Of Single)) As PointF @@ -185,6 +211,7 @@ Namespace Jobs.FinalizeDocument End Class Friend Class FormFieldValue + Public Property name As String Public Property value As String End Class End Class