Add configurable SignatureFieldParams class

Introduce `SignatureFieldParams` class to manage signature field dimensions with configurable `Width` and `Height`. Integrate this configuration into the service collection and replace hardcoded dimensions in `CreateEnvelopeCommandHandler.cs` and `SenderEditorPage.razor`. Update `appsettings.json` to include the new configuration section, allowing runtime adjustments.
This commit is contained in:
2026-10-27 09:18:11 +01:00
parent c2b7579717
commit 5df38754cb
7 changed files with 41 additions and 6 deletions

View File

@@ -7,11 +7,13 @@
@using EnvelopeGenerator.Application.Resources
@using EnvelopeGenerator.Domain.Constants
@using EnvelopeGenerator.Domain.Resources
@using EnvelopeGenerator.Application.Common.Configurations
@using EnvelopeGenerator.Server.Client.Components.PdfEditor
@using EnvelopeGenerator.Server.Client.Services
@using Microsoft.AspNetCore.WebUtilities
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.Extensions.Localization
@using Microsoft.Extensions.Options
@inject IJSRuntime JSRuntime
@inject NavigationManager NavigationManager
@inject AppVersionService AppVersion
@@ -25,6 +27,7 @@
@inject AuthService AuthService
@inject IStringLocalizer<Resource> UiLocalizer
@inject IStringLocalizer<Model> ModelLocalizer
@inject IOptionsMonitor<SignatureFieldParams> SignatureFieldOptions
<link href="_content/DevExpress.Blazor.Themes/blazing-berry.bs5.min.css" rel="stylesheet" />
<link href="_content/DevExpress.Blazor.Viewer/css/dx-blazor-viewer-components.bs5.css" rel="stylesheet" />
@@ -598,10 +601,11 @@
[SupplyParameterFromQuery(Name = "bootstrapToken")]
public string? BootstrapToken { get; set; }
// ── Constants ──
// Signature field size in PDF points (fixed): 1.77" × 1.96"
const double SigWidthPt = 1.77 * 72; // 127.44 pt
const double SigHeightPt = 1.96 * 72; // 141.12 pt
// ── Signature field size (configurable) ──
double SigWidthInches => SignatureFieldOptions.CurrentValue.Width;
double SigHeightInches => SignatureFieldOptions.CurrentValue.Height;
double SigWidthPt => SigWidthInches * 72.0;
double SigHeightPt => SigHeightInches * 72.0;
// CssClass for JS click coordinate helper
const string ViewerCssClass = "sender-editor-pdf-viewer";

View File

@@ -6,6 +6,7 @@ using DevExpress.XtraReports.Web.Extensions;
using DevExpress.DataAccess.Web;
using DevExpress.XtraReports.Services;
using System.Globalization;
using EnvelopeGenerator.Application.Common.Configurations;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
@@ -31,6 +32,8 @@ builder.Services.AddScoped(sp => new HttpClient
// Configuration Options
builder.Services.Configure<PdfViewerOptions>(opts =>
builder.Configuration.GetSection(PdfViewerOptions.SectionName).Bind(opts));
builder.Services.Configure<SignatureFieldParams>(opts =>
builder.Configuration.GetSection(nameof(SignatureFieldParams)).Bind(opts));
// Business Services
builder.Services.AddScoped<DocumentService>();

View File

@@ -58,6 +58,10 @@
"MainCanvasEnableHiDPI": true,
"ZoomStepPercentage": 5
},
"SignatureFieldParams": {
"Width": 1.77,
"Height": 1.96
},
"DocumentService": {
"BaseUrl": "http://172.24.12.39:9393"
},

View File

@@ -14,5 +14,9 @@
"RenderingOpacity": 0.85,
"ThumbnailRenderDelay": 50,
"ZoomStepPercentage": 5
},
"SignatureFieldParams": {
"Width": 1.77,
"Height": 1.96
}
}