diff --git a/DXApp.TemplateKitProject/Models/PdfExtractionResult.cs b/DXApp.TemplateKitProject/Models/PdfExtractionResult.cs index 31d0e47..9c774ce 100644 --- a/DXApp.TemplateKitProject/Models/PdfExtractionResult.cs +++ b/DXApp.TemplateKitProject/Models/PdfExtractionResult.cs @@ -9,6 +9,14 @@ public class PdfExtractionResult Attachments.FirstOrDefault(a => a.IsZugferdXml); public bool HasZugferdXml => ZugferdXmlAttachment is not null; + + // Welche PDF/A-Stufe hat das Dokument? + // Beispiel: "PDF/A-3b", "PDF/A-2b", oder "Kein PDF/A" + public string PdfALevel { get; set; } = string.Empty; + + // Soll eine Warnung angezeigt werden? + // true wenn kein PDF/A → ZUGFeRD-Rechnungen müssen PDF/A-3b sein + public bool PdfAWarning { get; set; } } public class ExtractedAttachment diff --git a/DXApp.TemplateKitProject/Pages/Invoices/Upload.cshtml b/DXApp.TemplateKitProject/Pages/Invoices/Upload.cshtml index 72c6e69..feb389b 100644 --- a/DXApp.TemplateKitProject/Pages/Invoices/Upload.cshtml +++ b/DXApp.TemplateKitProject/Pages/Invoices/Upload.cshtml @@ -42,6 +42,15 @@ } + @* PDF/A-Konformitätsstufe anzeigen *@ +
+ PDF/A-Konformität: @Model.Result.PdfALevel + @if (Model.Result.PdfAWarning) + { + – ⚠️ ZUGFeRD-Rechnungen müssen PDF/A-3b sein. + } +
+ diff --git a/DXApp.TemplateKitProject/Services/PdfAttachmentExtractorService.cs b/DXApp.TemplateKitProject/Services/PdfAttachmentExtractorService.cs index f9b9142..6a0066e 100644 --- a/DXApp.TemplateKitProject/Services/PdfAttachmentExtractorService.cs +++ b/DXApp.TemplateKitProject/Services/PdfAttachmentExtractorService.cs @@ -26,6 +26,22 @@ public class PdfAttachmentExtractorService( using var processor = new PdfDocumentProcessor(); processor.LoadDocument(pdfStream); + // PDF/A-Konformität prüfen + var compatibility = processor.Document.PdfACompatibility; + result.PdfALevel = compatibility switch + { + PdfACompatibility.None => "Kein PDF/A", + PdfACompatibility.PdfA1b => "PDF/A-1b", + PdfACompatibility.PdfA2b => "PDF/A-2b", + PdfACompatibility.PdfA3b => "PDF/A-3b", + _ => compatibility.ToString() + }; + result.PdfAWarning = compatibility == PdfACompatibility.None; + + logger.LogInformation( + "PDF '{FileName}': Konformität = {Level}", + sourceFileName, result.PdfALevel); + // Fix: .ToList() → IEnumerable → List mit Count-Property var attachments = processor.Document.FileAttachments.ToList();