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
This commit is contained in:
tekh 2025-11-07 13:03:50 +01:00
parent a386ad72bb
commit 339e0e81cd
2 changed files with 13 additions and 1 deletions

View File

@ -57,4 +57,16 @@ public class PDFBurnerParams
{ "city", 2 },
{ "date", 3 }
};
/// <summary>
///
/// </summary>
public int DefaultIndexOfAnnot { get; set; } = 0;
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public int GetAnnotationIndex(string name) => IndexOfAnnot.TryGetValue(name, out var value) ? value : DefaultIndexOfAnnot;
}

View File

@ -256,7 +256,7 @@ public class BurnPdfCommandHandler : IRequestHandler<BurnPdfCommand>
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();