refactor(PDFBurner): enhance annotation ID handling and validation

- Added parsing of annotation `id` into `envelopeId`, `receiverId`, `index`, and `internalType`.
- Added validation for `id` format, ensuring it has exactly 4 parts and numeric checks for relevant fields.
- Throws `BurnAnnotationException` if `id` is null, empty, or incorrectly formatted.
- Maintains existing functionality for adding image, ink, and widget annotations.
This commit is contained in:
tekh 2025-10-07 21:31:38 +02:00
parent a29f918125
commit b67f26cc21

View File

@ -193,7 +193,50 @@ Namespace Jobs.FinalizeDocument
End Class
Friend Class Annotation
Private _id As Integer
Public envelopeId As Integer
Public receiverId As Integer
Public index As Integer
Public internalType As String
Public Property id As String
Get
Return _id
End Get
Set(value As String)
_id = value
If String.IsNullOrWhiteSpace(id) Then
Throw New BurnAnnotationException("The identifier of annotation is null or empty.")
End If
Dim parts As String() = value.Split("-"c)
If (parts.Length <> 4) Then
Throw New BurnAnnotationException($"The identifier of annotation has more or less than 4 sub-part. Id: {_id}")
End If
If Not Integer.TryParse(parts(0), envelopeId) Then
Throw New BurnAnnotationException($"The envelope ID of annotation is not integer. Id: {_id}")
End If
If Not Integer.TryParse(parts(1), receiverId) Then
Throw New BurnAnnotationException($"The receiver ID of annotation is not integer. Id: {_id}")
End If
If Not Integer.TryParse(parts(2), index) Then
Throw New BurnAnnotationException($"The index of annotation is not integer. Id: {_id}")
End If
internalType = parts(3)
End Set
End Property
Public Property bbox As List(Of Double)
Public Property type As String
Public Property isSignature As Boolean