From 54f39103e1948178b9840905821389e66f2f34db Mon Sep 17 00:00:00 2001 From: Developer 02 Date: Thu, 24 Apr 2025 00:36:24 +0200 Subject: [PATCH] =?UTF-8?q?feat(IAnnotation):=20Hinzuf=C3=BCgen=20und=20Im?= =?UTF-8?q?plementieren=20der=20Eigenschaften=20BackgroundColor,=20BorderC?= =?UTF-8?q?olor,=20BorderStyle=20und=20BorderWidth.=20=20-=20Hintergrund?= =?UTF-8?q?=20mit=20neuen=20Eigenschaften=20in=20Annotations.js=20binden?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Models/Annotation/Annotation.cs | 10 ++++++++++ .../Models/Annotation/Background.cs | 10 ++++++++++ EnvelopeGenerator.Web/Models/Annotation/Color.cs | 10 ++++++++++ .../Models/Annotation/IAnnotation.cs | 8 ++++++++ EnvelopeGenerator.Web/appsettings.json | 14 +++++++++++++- EnvelopeGenerator.Web/wwwroot/js/annotation.js | 13 +++++++------ 6 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 EnvelopeGenerator.Web/Models/Annotation/Color.cs diff --git a/EnvelopeGenerator.Web/Models/Annotation/Annotation.cs b/EnvelopeGenerator.Web/Models/Annotation/Annotation.cs index 613ae395..ba85b509 100644 --- a/EnvelopeGenerator.Web/Models/Annotation/Annotation.cs +++ b/EnvelopeGenerator.Web/Models/Annotation/Annotation.cs @@ -60,6 +60,16 @@ public record Annotation : IAnnotation public Annotation? VerBoundAnnot { get; set; } #endregion + public Color? BackgroundColor { get; init; } + + #region Border + public Color? BorderColor { get; init; } + + public string? BorderStyle { get; init; } + + public int? BorderWidth { get; set; } + #endregion + [JsonIgnore] internal Annotation Default { diff --git a/EnvelopeGenerator.Web/Models/Annotation/Background.cs b/EnvelopeGenerator.Web/Models/Annotation/Background.cs index 7d05bfe1..381dddbd 100644 --- a/EnvelopeGenerator.Web/Models/Annotation/Background.cs +++ b/EnvelopeGenerator.Web/Models/Annotation/Background.cs @@ -21,6 +21,16 @@ public record Background : IAnnotation public double Top { get; set; } + public Color? BackgroundColor { get; init; } + + #region Border + public Color? BorderColor { get; init; } + + public string? BorderStyle { get; init; } + + public int? BorderWidth { get; set; } + #endregion + public void Locate(IEnumerable annotations) { // set Top diff --git a/EnvelopeGenerator.Web/Models/Annotation/Color.cs b/EnvelopeGenerator.Web/Models/Annotation/Color.cs new file mode 100644 index 00000000..0dc025be --- /dev/null +++ b/EnvelopeGenerator.Web/Models/Annotation/Color.cs @@ -0,0 +1,10 @@ +namespace EnvelopeGenerator.Web.Models.Annotation; + +public record Color +{ + public int R { get; init; } = 0; + + public int G { get; init; } = 0; + + public int B { get; init; } = 0; +} diff --git a/EnvelopeGenerator.Web/Models/Annotation/IAnnotation.cs b/EnvelopeGenerator.Web/Models/Annotation/IAnnotation.cs index 1bb30478..8f49b90a 100644 --- a/EnvelopeGenerator.Web/Models/Annotation/IAnnotation.cs +++ b/EnvelopeGenerator.Web/Models/Annotation/IAnnotation.cs @@ -11,4 +11,12 @@ public interface IAnnotation double Left { get; } double Top { get; } + + Color? BackgroundColor { get; } + + Color? BorderColor { get; } + + string? BorderStyle { get; } + + int? BorderWidth { get; } } diff --git a/EnvelopeGenerator.Web/appsettings.json b/EnvelopeGenerator.Web/appsettings.json index 380644e5..1c6fb8c4 100644 --- a/EnvelopeGenerator.Web/appsettings.json +++ b/EnvelopeGenerator.Web/appsettings.json @@ -152,7 +152,19 @@ "MainPageTitle": null, "AnnotationParams": { "Background": { - "Margin": 0.20 + "Margin": 0.20, + "BackgroundColor": { + "R": 222, + "G": 220, + "B": 215 + }, + "BorderColor": { + "R": 204, + "G": 202, + "B": 198 + }, + "BorderStyle": "underline", + "BorderWidth": 4 }, "DefaultAnnotation": { "Width": 1, diff --git a/EnvelopeGenerator.Web/wwwroot/js/annotation.js b/EnvelopeGenerator.Web/wwwroot/js/annotation.js index d2fcde76..c5ddf54f 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/annotation.js +++ b/EnvelopeGenerator.Web/wwwroot/js/annotation.js @@ -5,21 +5,22 @@ async function createAnnotations(document, instance) { for(var element of document.elements) { const annotParams = await getAnnotationParams(element.left, element.top); const page = element.page - 1 - + //background if(annotParams.background){ + let background = annotParams.background; const id_background = PSPDFKit.generateInstantId(); const annotation_background = new PSPDFKit.Annotations.WidgetAnnotation({ id: id_background, pageIndex: page, formFieldName: id_background, - backgroundColor: new PSPDFKit.Color({ r: 222, g: 220, b: 215 }), + backgroundColor: background?.backgroundColor ? new PSPDFKit.Color(background.backgroundColor) : null, blendMode: 'normal', - boundingBox: new PSPDFKit.Geometry.Rect(annotParams.background), + boundingBox: new PSPDFKit.Geometry.Rect(background), fontSize: 8, - borderStyle: 'underline', - borderWidth: 4, - borderColor: new PSPDFKit.Color({ r: 204, g: 202, b: 198 }) + borderStyle: background.borderStyle, + borderWidth: background.borderWidth, + borderColor: background?.borderColor ? new PSPDFKit.Color(background.borderColor) : null }); const formFieldBackground = new PSPDFKit.FormFields.ButtonFormField({