From f31f680f917f4940e4b445662cc1969b3f5d2c5e Mon Sep 17 00:00:00 2001 From: TekH Date: Fri, 7 Nov 2025 11:27:07 +0100 Subject: [PATCH] add PSPDFKit.Annotation --- .../Pdf/PSPDFKit/Annotation.cs | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 EnvelopeGenerator.Application/Pdf/PSPDFKit/Annotation.cs diff --git a/EnvelopeGenerator.Application/Pdf/PSPDFKit/Annotation.cs b/EnvelopeGenerator.Application/Pdf/PSPDFKit/Annotation.cs new file mode 100644 index 00000000..eacd0fe1 --- /dev/null +++ b/EnvelopeGenerator.Application/Pdf/PSPDFKit/Annotation.cs @@ -0,0 +1,98 @@ +using EnvelopeGenerator.Application.Exceptions; + +namespace EnvelopeGenerator.Application.Pdf.PSPDFKit; + +internal class Annotation +{ + private string? _id; + + public int EnvelopeId { get; private set; } = 0; + + public int ReceiverId { get; private set; } = 0; + + public int Index { get; private set; } = 0; + + public string EgName { get; private set; } = string.Empty; + + public bool HasStructuredID { get; private set; } = false; + + public bool IsLabel + { + get + { + if (string.IsNullOrEmpty(EgName)) + return false; + + var parts = EgName.Split('_'); + return parts.Length > 1 && parts[1] == "label"; + } + } + + public string? Id + { + get => _id; + set + { + _id = value; + + if (string.IsNullOrWhiteSpace(value)) + throw new BurnAnnotationException("The identifier of annotation is null or empty."); + + var parts = value.Split('#'); + + if (parts.Length != 4) + return; + // throw new BurnAnnotationException($"The identifier of annotation has more or less than 4 sub-part. Id: {_id}"); + + if (!int.TryParse(parts[0], out int envelopeId)) + throw new BurnAnnotationException($"The envelope ID of annotation is not integer. Id: {_id}"); + EnvelopeId = envelopeId; + + if (!int.TryParse(parts[1], out int receiverId)) + throw new BurnAnnotationException($"The receiver ID of annotation is not integer. Id: {_id}"); + ReceiverId = receiverId; + + if (!int.TryParse(parts[2], out int index)) + throw new BurnAnnotationException($"The index of annotation is not integer. Id: {_id}"); + Index = index; + + EgName = parts[3]; + HasStructuredID = true; + } + } + + /// + /// + /// + public List? Bbox { get; set; } + + /// + /// + /// + public string? Type { get; set; } + + /// + /// + /// + public bool IsSignature { get; set; } + + /// + /// + /// + public string? ImageAttachmentId { get; set; } + + /// + /// + /// + public Lines? Lines { get; set; } + + /// + /// + /// + public int PageIndex { get; set; } + + /// + /// + /// + public string? StrokeColor { get; set; } +} \ No newline at end of file