using DocumentService.Application.Common.Interfaces;
using FluentValidation;
using MediatR;
namespace DocumentService.Application.ConvertFromPdfA;
///
/// Command to convert a PDF/A document to a standard PDF (removes PDF/A restrictions)
///
public record ConvertFromPdfACommand : IRequest
{
///
/// PDF/A document stream. Must be positioned at the beginning (Position = 0).
///
public required Stream PdfStream { get; init; }
}
///
/// Handler for ConvertFromPdfACommand
///
public class ConvertFromPdfACommandHandler(IPdfProcessor pdfProcessor)
: IRequestHandler
{
public async Task Handle(ConvertFromPdfACommand request, CancellationToken cancellationToken)
{
return await pdfProcessor.ConvertFromPdfAAsync(request.PdfStream);
}
}
///
/// Validator for ConvertFromPdfACommand
///
public class ConvertFromPdfACommandValidator : AbstractValidator
{
public ConvertFromPdfACommandValidator()
{
RuleFor(x => x.PdfStream)
.NotNull()
.WithMessage("PDF stream is required");
}
}