Enhanced `PdfExtractionResult` with a new `ZugferdGuidelineId` property to store the ZUGFeRD Guideline-ID extracted from XMP metadata. Updated `Upload.cshtml` to display this information in the UI if available. Implemented ZUGFeRD Guideline-ID extraction in `PdfAttachmentExtractorService` using a new helper method `ExtractGuidelineId`, which parses XMP metadata for known prefixes. Added logging for extracted Guideline-IDs and improved error handling with a `try-catch` block for metadata processing. Fixed `FileAttachments` handling in `PdfAttachmentExtractorService` by converting to `List<T>` for proper `Count` property usage.
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
namespace DXApp.TemplateKitProject.Models;
|
|
|
|
public class PdfExtractionResult
|
|
{
|
|
public List<ExtractedAttachment> Attachments { get; init; } = [];
|
|
public bool HasAttachments => Attachments.Count > 0;
|
|
|
|
public ExtractedAttachment? ZugferdXmlAttachment =>
|
|
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; }
|
|
|
|
// ZUGFeRD Guideline-ID aus XMP-Metadaten
|
|
// Beispiel: "urn:ferd:invoice:rc:comfort"
|
|
// Leer wenn keine ZUGFeRD-Metadaten gefunden
|
|
public string ZugferdGuidelineId { get; set; } = string.Empty;
|
|
}
|
|
|
|
public class ExtractedAttachment
|
|
{
|
|
public string OriginalFileName { get; init; }
|
|
public string SavedFilePath { get; init; }
|
|
public long FileSizeBytes { get; init; }
|
|
public bool IsZugferdXml { get; init; }
|
|
} |