Commit Graph

6 Commits

Author SHA1 Message Date
1de781748b refactor: Update DevExpressPdfProcessor to use Stream parameters
- All 3 methods (ValidateAsync, ValidatePdfAAsync, CheckAttachmentsAsync) now accept Stream
- Add ArgumentNullException.ThrowIfNull() checks for null streams
- Implement fast-path optimization: reuse MemoryStream buffer when possible
- Implement slow-path fallback: copy stream to byte[] for DevExpress API compatibility
- Fix namespace collision: use fully qualified Application.Common.DTOs.PdfMetadata
2026-07-20 11:55:17 +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
OlgunR
18e956c2cf Enhance PDF attachment detection and counting
Refactored `DevExpressPdfProcessor` to improve attachment detection:
- Changed `DetectEmbeddedFiles` return type to a tuple for better
  handling of attachment presence and count.
- Enhanced logic to parse `/Names` arrays and count object references
  for accurate attachment detection.
- Implemented robust search for `/EmbeddedFiles` to handle multiple
  occurrences and ensure proper context validation.

Updated PHASENPLAN.md and ROADMAP.md to reflect these changes, including
the addition of fixes for attachment detection and counting logic.

Added new tests in `DevExpressPdfProcessorTests`:
- Verified detection of multiple attachments and accurate counts.
- Ensured no crashes when processing PDFs with `/EmbeddedFiles`.

Included a new test resource (`pdfWithMoreThanOneAttachment.pdf`) for
validating multiple attachment scenarios.
2026-06-25 17:17:32 +02:00
OlgunR
1b38d5a729 Implement attachment detection in ValidatePDF
Updated PHASENPLAN.md and ROADMAP.md to reflect a complete restructuring of the development plan and added a "Bugfix: Attachment Detection" entry.

Implemented attachment detection in DevExpressPdfProcessor.cs using the new `DetectEmbeddedFiles` method, which scans raw PDF data for the `/EmbeddedFiles` keyword. Updated the `hasAttachments` property to use this method and set `attachmentCount` to `-1` when attachments are detected.

Added a new test, `ValidateAsync_PdfWithoutAttachments_ReturnsNoAttachments`, in DevExpressPdfProcessorTests.cs to verify that PDFs without attachments are correctly identified. Included a note about future testing for PDFs with attachments using ZUGFeRD files.

All related tests are passing (12/12 green).
2026-06-25 16:25:16 +02:00
OlgunR
5ac0777e5b Remove duplicate using directive in DevExpressPdfProcessor.cs
Eliminated a redundant `using DevExpress.Pdf;` statement to improve code readability and maintain cleaner imports. This change has no functional impact but enhances code clarity.
2026-06-23 13:09:58 +02:00
OlgunR
b1d48418cf Migrate to DevExpress.Document.Processor library
Replaced `DevExpress.Pdf.Core` with `DevExpress.Document.Processor` in `DocumentOperator.Infrastructure.csproj` to adopt a newer library for PDF processing. Removed the `Services\PdfProcessing\` folder reference.

Updated `DevExpressPdfProcessorTests` to reflect changes in the `ValidateAsync` method's behavior.

Introduced the `DevExpressPdfProcessor` class, implementing the `IPdfProcessor` interface. This class validates PDF documents and extracts metadata using the `DevExpress.Pdf` library. Added defensive input validation, metadata extraction, and exception handling for domain consistency.
2026-06-23 10:33:43 +02:00