From 339e0e81cd33691d98b1e835e3930112750a9afd Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 7 Nov 2025 13:03:50 +0100 Subject: [PATCH] feat(PDFBurnerParams): add DefaultIndexOfAnnot and GetAnnotationIndex - add `DefaultIndexOfAnnot` property to provide a fallback index for annotations - add `GetAnnotationIndex(string name)` method to safely retrieve an annotation index, returning default if not found --- .../Common/Configurations/PDFBurnerParams.cs | 12 ++++++++++++ EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/EnvelopeGenerator.Application/Common/Configurations/PDFBurnerParams.cs b/EnvelopeGenerator.Application/Common/Configurations/PDFBurnerParams.cs index 60e19579..d0d090af 100644 --- a/EnvelopeGenerator.Application/Common/Configurations/PDFBurnerParams.cs +++ b/EnvelopeGenerator.Application/Common/Configurations/PDFBurnerParams.cs @@ -57,4 +57,16 @@ public class PDFBurnerParams { "city", 2 }, { "date", 3 } }; + + /// + /// + /// + public int DefaultIndexOfAnnot { get; set; } = 0; + + /// + /// + /// + /// + /// + public int GetAnnotationIndex(string name) => IndexOfAnnot.TryGetValue(name, out var value) ? value : DefaultIndexOfAnnot; } \ No newline at end of file diff --git a/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs b/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs index e8bc6f9e..86d36920 100644 --- a/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs +++ b/EnvelopeGenerator.Application/Pdf/BurnPdfCommand.cs @@ -256,7 +256,7 @@ public class BurnPdfCommandHandler : IRequestHandler private void AddFormFieldValue(Annotation pAnnotation, FormFieldValue formFieldValue) { - var ffIndex = _pdfBurnerParams.IndexOfAnnot[pAnnotation.EgName]; + var ffIndex = _pdfBurnerParams.GetAnnotationIndex(pAnnotation.EgName); // Convert pixels to Inches var oBounds = pAnnotation.Bbox?.Select(ToInches).ToList();