浏览代码

Document operation: added ExtendMetadata section

Marcin Ziąbek 1 年之前
父节点
当前提交
82e96a0346
共有 2 个文件被更改,包括 20 次插入0 次删除
  1. 19 0
      Source/QuestPDF/Fluent/DocumentOperation.cs
  2. 1 0
      Source/QuestPDF/Qpdf/JobConfiguration.cs

+ 19 - 0
Source/QuestPDF/Fluent/DocumentOperation.cs

@@ -306,6 +306,25 @@ public class DocumentOperation
         
         return this;
     }
+
+    /// <summary>
+    /// Extends the current document's XMP metadata by adding content within the <c>rdf:Description</c> tag.
+    /// This allows for adding additional descriptive metadata to the PDF, which is useful for compliance standards
+    /// like PDF/A or for industry-specific metadata (e.g., ZUGFeRD).
+    /// </summary>
+    /// <param name="metadata">
+    /// A string containing the metadata to add. This metadata must be valid XML content and conform to the
+    /// RDF structure required by the PDF XMP metadata specification.
+    /// </param>
+    public DocumentOperation ExtendMetadata(string metadata)
+    {
+        Configuration.ExtendMetadata = metadata
+            .Replace("\"", "\\\"")
+            .Replace("\n", "\\n")
+            .Replace("\r", "");
+        
+        return this;
+    }
     
     /// <summary>
     /// Adds an attachment to the document, with specified metadata and configuration options.

+ 1 - 0
Source/QuestPDF/Qpdf/JobConfiguration.cs

@@ -15,6 +15,7 @@ class JobConfiguration
     [Name("overlay")] public ICollection<LayerConfiguration>? Overlay { get; set; }
     [Name("underlay")] public ICollection<LayerConfiguration>? Underlay { get; set; }
 
+    [Name("extendMetadata")] public string? ExtendMetadata { get; set; }
     [Name("addAttachment")] public ICollection<AddDocumentAttachment>? AddAttachment { get; set; }
     
     [Name("encrypt")] public EncryptionSettings? Encrypt { get; set; }