feat(IAnnotation): Hinzufügen und Implementieren der Eigenschaften BackgroundColor, BorderColor, BorderStyle und BorderWidth.

- Hintergrund mit neuen Eigenschaften in Annotations.js binden
This commit is contained in:
Developer 02 2025-04-24 00:36:24 +02:00
parent 8b505ae39a
commit 54f39103e1
6 changed files with 58 additions and 7 deletions

View File

@ -60,6 +60,16 @@ public record Annotation : IAnnotation
public Annotation? VerBoundAnnot { get; set; } public Annotation? VerBoundAnnot { get; set; }
#endregion #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] [JsonIgnore]
internal Annotation Default internal Annotation Default
{ {

View File

@ -21,6 +21,16 @@ public record Background : IAnnotation
public double Top { get; set; } 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<IAnnotation> annotations) public void Locate(IEnumerable<IAnnotation> annotations)
{ {
// set Top // set Top

View File

@ -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;
}

View File

@ -11,4 +11,12 @@ public interface IAnnotation
double Left { get; } double Left { get; }
double Top { get; } double Top { get; }
Color? BackgroundColor { get; }
Color? BorderColor { get; }
string? BorderStyle { get; }
int? BorderWidth { get; }
} }

View File

@ -152,7 +152,19 @@
"MainPageTitle": null, "MainPageTitle": null,
"AnnotationParams": { "AnnotationParams": {
"Background": { "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": { "DefaultAnnotation": {
"Width": 1, "Width": 1,

View File

@ -5,21 +5,22 @@ async function createAnnotations(document, instance) {
for(var element of document.elements) { for(var element of document.elements) {
const annotParams = await getAnnotationParams(element.left, element.top); const annotParams = await getAnnotationParams(element.left, element.top);
const page = element.page - 1 const page = element.page - 1
//background //background
if(annotParams.background){ if(annotParams.background){
let background = annotParams.background;
const id_background = PSPDFKit.generateInstantId(); const id_background = PSPDFKit.generateInstantId();
const annotation_background = new PSPDFKit.Annotations.WidgetAnnotation({ const annotation_background = new PSPDFKit.Annotations.WidgetAnnotation({
id: id_background, id: id_background,
pageIndex: page, pageIndex: page,
formFieldName: id_background, formFieldName: id_background,
backgroundColor: new PSPDFKit.Color({ r: 222, g: 220, b: 215 }), backgroundColor: background?.backgroundColor ? new PSPDFKit.Color(background.backgroundColor) : null,
blendMode: 'normal', blendMode: 'normal',
boundingBox: new PSPDFKit.Geometry.Rect(annotParams.background), boundingBox: new PSPDFKit.Geometry.Rect(background),
fontSize: 8, fontSize: 8,
borderStyle: 'underline', borderStyle: background.borderStyle,
borderWidth: 4, borderWidth: background.borderWidth,
borderColor: new PSPDFKit.Color({ r: 204, g: 202, b: 198 }) borderColor: background?.borderColor ? new PSPDFKit.Color(background.borderColor) : null
}); });
const formFieldBackground = new PSPDFKit.FormFields.ButtonFormField({ const formFieldBackground = new PSPDFKit.FormFields.ButtonFormField({