refactor(PDFBurner): adjust annotation positioning and unit conversions in PDFBurner
- 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
This commit is contained in:
parent
b9bb058137
commit
a11d9a0e0e
@ -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))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user