Add interfaces and DTOs for PDF operations support
Introduced multiple interfaces and DTOs to support a wide range of PDF-related operations, including attachment handling, conversion, validation, annotation, stamping, and metadata extraction. Key changes: - Added `DocumentServiceClientOptions` for HTTP client config. - Introduced `IPdfAttachmentClient` for attachment operations. - Added `IPdfConversionClient` for PDF/A conversion (marked obsolete). - Added `IPdfOperationsClient` for merge, annotate, and stamp ops. - Introduced `IPdfValidationClient` for PDF and PDF/A validation. - Added `ISwissQrCodeClient` for Swiss QR Code extraction. - Added `IZugferdClient` for ZUGFeRD detection and extraction. - Created request DTOs for Base64-encoded operations. - Added enums for annotation, stamp, and validation configurations. These changes provide a flexible and extensible foundation for interacting with PDF documents, supporting both multipart and Base64-encoded inputs, and ensuring type safety with enums and records.
This commit is contained in:
75
DocumentService.Client/Interfaces/IPdfValidationClient.cs
Normal file
75
DocumentService.Client/Interfaces/IPdfValidationClient.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
namespace DocumentService.Client.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Client for PDF validation operations (validate, validate PDF/A).
|
||||
/// </summary>
|
||||
public interface IPdfValidationClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Validates a PDF from stream (multipart upload).
|
||||
/// </summary>
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Validation result with metadata</returns>
|
||||
Task<PdfValidationResult> ValidatePdfAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a PDF from byte array (Base64 JSON).
|
||||
/// </summary>
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Validation result with metadata</returns>
|
||||
Task<PdfValidationResult> ValidatePdfAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a PDF/A from stream (multipart upload).
|
||||
/// </summary>
|
||||
/// <param name="pdfStream">PDF/A file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>PDF/A validation result with conformance level and errors</returns>
|
||||
Task<PdfAValidationResult> ValidatePdfAAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Validates a PDF/A from byte array (Base64 JSON).
|
||||
/// </summary>
|
||||
/// <param name="pdfBytes">PDF/A file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>PDF/A validation result with conformance level and errors</returns>
|
||||
Task<PdfAValidationResult> ValidatePdfAAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for PDF validation result
|
||||
/// </summary>
|
||||
public record PdfValidationResult
|
||||
{
|
||||
/// <summary>Total number of pages in the document.</summary>
|
||||
public int PageCount { get; init; }
|
||||
/// <summary>File size in bytes.</summary>
|
||||
public long FileSizeBytes { get; init; }
|
||||
/// <summary>PDF specification version (e.g. "1.7").</summary>
|
||||
public string PdfVersion { get; init; } = string.Empty;
|
||||
/// <summary>Whether the document is password-protected.</summary>
|
||||
public bool IsEncrypted { get; init; }
|
||||
/// <summary>Whether the document contains embedded file attachments.</summary>
|
||||
public bool HasAttachments { get; init; }
|
||||
/// <summary>Number of embedded file attachments.</summary>
|
||||
public int AttachmentCount { get; init; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for PDF/A validation result
|
||||
/// </summary>
|
||||
public record PdfAValidationResult
|
||||
{
|
||||
/// <summary>Whether the document is fully PDF/A conformant.</summary>
|
||||
public bool IsValid { get; init; }
|
||||
/// <summary>Detected PDF/A conformance level (e.g. "PDF/A-3b"), or <c>null</c> if not a PDF/A document.</summary>
|
||||
public string? PdfAVersion { get; init; }
|
||||
/// <summary>Total number of pages in the document.</summary>
|
||||
public int PageCount { get; init; }
|
||||
/// <summary>List of conformance errors found during validation.</summary>
|
||||
public List<string> Errors { get; init; } = new();
|
||||
/// <summary>List of conformance warnings found during validation.</summary>
|
||||
public List<string> Warnings { get; init; } = new();
|
||||
}
|
||||
Reference in New Issue
Block a user