feat(application): add DocumentOperator.Application PDF signing contracts
This commit is contained in:
22
DocumentOperator.Application/SignPdf/SignPdfCommand.cs
Normal file
22
DocumentOperator.Application/SignPdf/SignPdfCommand.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using DocumentOperator.Application.Common.Dto;
|
||||
using DocumentOperator.Application.Common.Interfaces.Services;
|
||||
using MediatR;
|
||||
|
||||
namespace DocumentOperator.Application.SignPdf;
|
||||
|
||||
public sealed record SignPdfCommand : IRequest<byte[]>
|
||||
{
|
||||
public required Stream InputPdf { get; init; }
|
||||
public required PdfSignOptionsDto Options { get; init; }
|
||||
public Stream? SignatureImage { get; init; }
|
||||
}
|
||||
|
||||
public sealed class SignPdfCommandHandler(IPdfDigitalSignatureService signer) : IRequestHandler<SignPdfCommand, byte[]>
|
||||
{
|
||||
public async Task<byte[]> Handle(SignPdfCommand command, CancellationToken cancellationToken)
|
||||
{
|
||||
using var output = new MemoryStream();
|
||||
await signer.SignPdfAsync(command.InputPdf, output, command.Options, command.SignatureImage, cancellationToken);
|
||||
return output.ToArray();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user