From a11d9a0e0edc4900c9c7b3d7c5016c5168d36ccb Mon Sep 17 00:00:00 2001 From: TekH Date: Tue, 28 Oct 2025 15:27:52 +0100 Subject: [PATCH] refactor(PDFBurner): adjust annotation positioning and unit conversions in PDFBurner MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Renamed variable `magin` → `margin` for clarity - Revised coordinate calculations for annotation positioning (`x`, `y`) - Adjusted width and height units to use inches instead of fixed inchFactor multipliers - Updated y-offset logic for form fields (`yOffsetsOfFF`) to improve layout alignment - Simplified image annotation scaling (removed division by 100) - Improved code readability and comment consistency --- .../Jobs/FinalizeDocument/PDFBurner.vb | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb index a5bdb7de..2b2c00d6 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb @@ -60,31 +60,32 @@ Namespace Jobs.FinalizeDocument Throw New BurnAnnotationException($"Could not open document for burning: [{oResult}]") End If - 'imported from background (add to configuration) + ' Imported from background (add to configuration) + Dim margin As Double = 0.2 Dim inchFactor As Double = 72 - Dim magin As Double = 0.2 - Dim width As Double = 1.9500000000000002 * inchFactor - Dim height As Double = 2.52 * inchFactor + ' Y offset of form fields Dim keys = {"position", "city", "date"} ' add to configuration Dim unitYOffsets = 0.2 - Dim yOffsets = keys. - Select(Function(k, i) New With {Key .Key = k, Key .Value = unitYOffsets * i}). + Dim yOffsetsOfFF = keys. + Select(Function(k, i) New With {Key .Key = k, Key .Value = unitYOffsets * i + 1}). ToDictionary(Function(x) x.Key, Function(x) x.Value) 'Add annotations For Each element In elements - Dim x = (element.Left - 0.7 - magin) + Dim x = (element.Left - 0.7 - margin) For Each annot In element.Annotations - Dim yOffset As Double = If(yOffsets.TryGetValue(annot.Name, yOffset), yOffset, 0) - Dim y = element.Top + yOffset + Dim yOffsetofFF As Double = If(yOffsetsOfFF.TryGetValue(annot.Name, yOffsetofFF), yOffsetofFF, 0) + + 'double y = (signature.Y - .5 - magin) * inchFactor + Dim y = element.Top - 0.5 - margin + yOffsetofFF If annot.Type = AnnotationType.FormField Then - AddFormFieldValue(x, y, width, height, element.Page, annot.Value) + AddFormFieldValue(x, y, annot.Width / inchFactor, annot.Height / inchFactor, element.Page, annot.Value) ElseIf annot.Type = AnnotationType.Image Then - AddImageAnnotation(x, y, width, height, element.Page, annot.Value) + AddImageAnnotation(x, y, annot.Width / inchFactor, annot.Height / inchFactor, element.Page, annot.Value) ElseIf annot.Type = AnnotationType.Ink Then AddInkAnnotation(element.Page, annot.Value) End If @@ -175,7 +176,7 @@ Namespace Jobs.FinalizeDocument Private Sub AddImageAnnotation(x As Double, y As Double, width As Double, height As Double, page As Integer, base64 As String) Manager.SelectPage(page) - Manager.AddEmbeddedImageAnnotFromBase64(base64, x, y, width / 100, height / 100) + Manager.AddEmbeddedImageAnnotFromBase64(base64, x, y, width, height) End Sub Private Sub AddImageAnnotation(pAnnotation As Annotation, pAttachments As Dictionary(Of String, Attachment))