Commit Graph

14 Commits

Author SHA1 Message Date
0e88b349d7 Rebrand project: DocumentOperator to DocumentService
This commit implements a complete rebranding of the project:
- Updated all namespaces from `DocumentOperator` to `DocumentService`.
- Renamed file paths, embedded resources, and test data references.
- Updated configuration keys, logging paths, and Redis instance names.
- Revised documentation to reflect the new project name.
- Modified project and solution files to align with the new structure.
- Updated class names, DTOs, commands, queries, and handlers.
- Adjusted middleware, controllers, and API endpoints.
- Updated Swagger metadata and API titles to `DocumentService API`.
- Refactored test namespaces, resource paths, and embedded resources.
- Updated build and deployment configurations for the new name.
- Replaced all references to `DocumentOperator` in comments and literals.

These changes ensure consistency across the codebase and documentation.
2026-07-30 14:02:56 +02:00
a6694bfce7 Add PDF attachment and PDF/A conversion features
Introduced endpoints for embedding attachments in PDFs and converting
between standard PDFs and PDF/A formats. Added `PdfAttachmentController`
and `PdfConversionController` with multipart/form-data and Base64-based
support. Implemented commands, handlers, and validators for these
operations.

Extended `IPdfProcessor` with methods for adding attachments and
PDF/A conversion. Partially implemented functionality in
`DevExpressPdfProcessor`, including `ConvertFromPdfAAsync`.

Added `attachment.xml` and `withoutAttachment.pdf` as resources for
testing. Marked endpoints as `[Obsolete]` to indicate incomplete
implementation. Improved validation and error handling for commands.
2026-07-30 13:43:55 +02:00
a242458d2f Add support for XML file output in ZUGFeRD extraction
Enhanced `ExtractZugferdFromFile` and `ExtractZugferdFromBase64`
methods to support output as an XML file (`application/xml`)
or JSON (default). Introduced `asFile` and `format` query
parameters to control the output format. Updated XML
documentation and `ProducesResponseType` attributes to reflect
these changes. Default values for `CancellationToken` were
set to `default` for improved usability.
2026-07-30 10:47:48 +02:00
94123cd1be Add ZUGFeRD detection and extraction functionality
Introduced `ZugferdController` to handle ZUGFeRD-related operations, including detection and extraction of ZUGFeRD XML from PDFs via file upload or Base64-encoded payloads. Integrated `MediatR` for query/command handling.

Added `ZugferdSettings` for configurable file names and patterns, and updated `appsettings.json` and `Program.cs` to support this configuration.

Implemented `HasZugferdQuery` and `ExtractZugferdCommand` with their respective handlers and validators. Added DTOs (`ZugferdCheckResult`, `ZugferdExtractionResult`) for operation results.

Included `ZUGFeRD-Example.pdf` for testing and integrated `Serilog.Ui.Core.Extensions` for logging.
2026-07-30 10:16:43 +02:00
61b11fc216 feat(annotation): Add Origin/Width/Height to API endpoints
- Update AddAnnotationFromFile/AddAnnotationFromBase64 endpoints
- Add Origin parameter to multipart/JSON request DTOs
- Add Width/Height as alternative to X2/Y2 in requests
- Calculate X2/Y2 from Width/Height if provided
- XML documentation updated with new parameters
2026-07-21 14:38:14 +02:00
d4107f6f89 feat(api): Add annotation endpoints to PdfOperationsController
- Add POST /api/pdf/operations/annotate (multipart/form-data)
- Add POST /api/pdf/operations/annotate (application/json with Base64)
- Create AddAnnotationMultipartRequest DTO (wrapper for 10+ form parameters)
- Create AddAnnotationBase64Command DTO (Base64 PDF + annotation parameters)
- Add unique operation names (AnnotateFromFile, AnnotateFromBase64) for Swagger
- Rename MergePdfsRequest -> MergePdfsBase64Request for clarity
- Add Name attributes to merge endpoints (MergeFromFiles, MergeFromBase64) to fix Swagger conflict
- Base64 FormatException wrapped in BadRequestException
2026-07-21 12:28:43 +02:00
5c3fafff1b feat: Add PdfOperationsController with dual-input merge endpoints
- Add PdfOperationsController.cs with route '/api/pdf/operations'
- MergeFromFiles: POST /merge (multipart/form-data) - accepts List<IFormFile>
- MergeFromBase64: POST /merge (application/json) - accepts MergePdfsRequest DTO
- Returns merged PDF as FileContentResult (application/pdf)
- Supports optional page ranges via JSON endpoint only (multipart binding complex)
- XML documentation with response codes (200, 400, 500)
- Uses primary constructor pattern
2026-07-21 10:21:27 +02:00
34e38f19e5 feat: Add PdfAttachmentController extract endpoints (multipart + Base64) 2026-07-21 09:26:34 +02:00
b4befde418 refactor(api): migrate controllers to Stream API with Base64 validation
PdfValidationController:
- ValidateFromFile: IFormFile.OpenReadStream() direct usage (no byte[] copy)
- ValidateFromBase64: try-catch Convert.FromBase64String → BadRequestException
- ValidatePdfAFromFile: IFormFile.OpenReadStream() direct usage
- ValidatePdfAFromBase64: try-catch Convert.FromBase64String → BadRequestException

PdfAttachmentController:
- CheckAttachmentsFromBase64: try-catch Convert.FromBase64String → BadRequestException

SwissQrCodeController:
- ExtractFromBase64: try-catch Convert.FromBase64String → BadRequestException

All controllers: Add using DocumentOperator.Domain.Common.Exceptions for BadRequestException
2026-07-20 16:32:03 +02:00
9db15f7025 feat: Add PdfAttachmentController with CheckAttachments endpoints
- Add POST /api/pdf/attachments/check endpoint (multipart/form-data)
- Add POST /api/pdf/attachments/check endpoint (application/json with Base64)
- Dual input support: IFormFile (file upload) and Base64 JSON
- Controller converts IFormFile → byte[] and sends to MediatR
- Complete XML documentation with Swagger examples
- Primary constructor pattern used
2026-07-20 11:56:12 +02:00
4085a88485 Update XML docs for raw param in SwissQrCodeController
Removed detailed description of the `raw` parameter in XML
documentation for two methods in `SwissQrCodeController`.
Updated `<returns>` tag to simplify the explanation by
removing conditional details based on the `raw` parameter.
These changes affect methods handling multipart/form-data
PDF input and Base64 JSON input.
2026-07-20 10:51:30 +02:00
a315fbf890 feat: Add raw parameter to SwissQrCodeController endpoints
- Add 'raw' query parameter to both ExtractFromFile and ExtractFromBase64 methods
- Returns raw QR text lines when raw=true, parsed Bill object when raw=false (default)
- Remove obsolete 'references' parameter (not part of QR extraction logic)
- Add XML documentation for raw parameter
- Update ExceptionHandlingMiddleware to handle BadRequestException
2026-07-16 15:48:09 +02:00
cd50d45bd5 feat: Add PDF/A validation endpoint (Feature 3)
Domain layer:

  - PdfAMetadata value object (isValid, pdfVersion, pageCount, encrypted, pdfaVersion, pdfaCompliant, errors, warnings)

Infrastructure layer:

  - IPdfProcessor.ValidatePdfAAsync() interface method

  - DevExpressPdfProcessor.ValidatePdfAAsync() implementation

  - DetectEncryption() - scans PDF raw data for /Encrypt keyword

  - DetectPdfAConformance() - parses XMP metadata (pdfaid:part, pdfaid:conformance)

  - Validation: encrypted PDF cannot be PDF/A compliant

Application layer:

  - ValidatePdfAQuery + ValidatePdfAQueryHandler (co-located)

  - ValidatePdfAQueryValidator (FluentValidation: PdfBytes XOR Base64Pdf)

  - PdfAValidationResult DTO

  - AutoMapper: PdfAMetadata -> PdfAValidationResult

API layer:

  - PdfValidationController.ValidatePdfAFromFile() (multipart/form-data)

  - PdfValidationController.ValidatePdfAFromBase64() (application/json)

  - XML documentation with response codes

Result:

  - POST /api/pdf/validation/validate-pdfa (both multipart and JSON)

  - Returns: conformance level, errors, warnings

  - Build: 0 errors, 4 warnings (DevExpress eval)

  - Tests: 20/20 passing

Next: Integration tests + Swagger test case
2026-07-09 12:59:24 +02:00
57e36fc004 refactor: Migrate from Minimal API to Controller-based API
Architecture decision change:

  - Previous: Minimal API (DocumentEndpoints.cs) - WRONG approach

  - Required: Controller-based API (per CONTROLLER_ENDPOINTS.md)

New controllers:

  - PdfValidationController:

    - POST /api/pdf/validation/validate

    - Accepts BOTH IFormFile (multipart) AND Base64 JSON

    - Returns PdfValidationResult

  - SwissQrCodeController:

    - POST /api/swissqrcode/extract

    - Accepts BOTH IFormFile (multipart) AND Base64 JSON

    - Returns SwissQrCodeExtractionResult

Controller best practices:

  - Primary constructors (C# 12)

  - Thin controllers (pass request to MediatR directly)

  - No manual mapping (AutoMapper handles domain -> DTO)

  - XML documentation for Swagger

  - [ProducesResponseType] attributes

Deleted:

  - API/Endpoints/v1/DocumentEndpoints.cs (Minimal API)

  - ROADMAP.md (conflicting guidance with CONTROLLER_ENDPOINTS.md)

Result: Controller-based API, dual input support (multipart + JSON)
2026-07-07 19:01:20 +02:00