diff --git a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb index b3329496..781615ac 100644 --- a/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb +++ b/EnvelopeGenerator.CommonServices/Jobs/FinalizeDocument/PDFBurner.vb @@ -37,6 +37,15 @@ Namespace Jobs.FinalizeDocument Public Function BurnAnnotsToPDF(pSourceBuffer As Byte(), pInstantJSONList As List(Of String), envelopeId As Integer) As Byte() 'read the elements of envelope with their annotations Using scope = Factory.Shared.ScopeFactory.CreateScope() + + Dim envRepo = scope.ServiceProvider.Repository(Of Envelope)() + Dim envelope = envRepo.Where(Function(env) env.Id = envelopeId).FirstOrDefault() + If envelope Is Nothing Then + Throw New BurnAnnotationException($"Envelope with Id {envelopeId} not found.") + ElseIf envelope.ReadOnly Then + Return pSourceBuffer + End If + Dim sigRepo = scope.ServiceProvider.Repository(Of Signature)() Dim elements = sigRepo _ .Where(Function(sig) sig.Document.EnvelopeId = envelopeId) _