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:
89
DocumentService.Client/Interfaces/IPdfAttachmentClient.cs
Normal file
89
DocumentService.Client/Interfaces/IPdfAttachmentClient.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using DocumentService.Client.Models.Requests;
|
||||
|
||||
namespace DocumentService.Client.Interfaces;
|
||||
|
||||
/// <summary>
|
||||
/// Client for PDF attachment operations (check, extract, add).
|
||||
/// </summary>
|
||||
public interface IPdfAttachmentClient
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if PDF contains attachments (multipart).
|
||||
/// </summary>
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Attachment check result with metadata</returns>
|
||||
Task<AttachmentCheckResult> CheckAttachmentsAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Checks if PDF contains attachments (Base64).
|
||||
/// </summary>
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Attachment check result with metadata</returns>
|
||||
Task<AttachmentCheckResult> CheckAttachmentsAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all embedded attachments from a PDF (multipart).
|
||||
/// The returned dictionary maps each file name to its decompressed content stream.
|
||||
/// </summary>
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Dictionary of file name ? content stream for each extracted attachment</returns>
|
||||
Task<Dictionary<string, Stream>> ExtractAttachmentsAsync(Stream pdfStream, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Extracts all embedded attachments from a PDF (Base64).
|
||||
/// The returned dictionary maps each file name to its decompressed content stream.
|
||||
/// </summary>
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Dictionary of file name ? content stream for each extracted attachment</returns>
|
||||
Task<Dictionary<string, Stream>> ExtractAttachmentsAsync(byte[] pdfBytes, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Adds attachments to PDF (multipart). ?? Not implemented yet in API.
|
||||
/// </summary>
|
||||
/// <param name="pdfStream">PDF file stream</param>
|
||||
/// <param name="attachments">Attachments to add</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Modified PDF as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> AddAttachmentsAsync(Stream pdfStream, List<AttachmentRequestDto> attachments, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Adds attachments to PDF (Base64). ?? Not implemented yet in API.
|
||||
/// </summary>
|
||||
/// <param name="pdfBytes">PDF file as byte array</param>
|
||||
/// <param name="attachments">Attachments to add</param>
|
||||
/// <param name="cancellationToken">Cancellation token</param>
|
||||
/// <returns>Modified PDF as stream</returns>
|
||||
[Obsolete("API endpoint not implemented yet")]
|
||||
Task<Stream> AddAttachmentsAsync(byte[] pdfBytes, List<AttachmentRequestDto> attachments, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for attachment check result
|
||||
/// </summary>
|
||||
public record AttachmentCheckResult
|
||||
{
|
||||
/// <summary>Whether the document contains any embedded file attachments.</summary>
|
||||
public bool HasAttachments { get; init; }
|
||||
/// <summary>Number of embedded file attachments found.</summary>
|
||||
public int AttachmentCount { get; init; }
|
||||
/// <summary>Metadata for each attachment found in the document.</summary>
|
||||
public List<AttachmentMetadata> Attachments { get; init; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DTO for attachment metadata
|
||||
/// </summary>
|
||||
public record AttachmentMetadata
|
||||
{
|
||||
/// <summary>Name of the embedded file.</summary>
|
||||
public string FileName { get; init; } = string.Empty;
|
||||
/// <summary>MIME type of the embedded file (e.g. "application/xml"), or <c>null</c> if unknown.</summary>
|
||||
public string? MimeType { get; init; }
|
||||
/// <summary>Size of the embedded file in bytes.</summary>
|
||||
public long Size { get; init; }
|
||||
}
|
||||
Reference in New Issue
Block a user