feat: added additional meta data attributes

This commit is contained in:
2026-02-05 19:49:28 +01:00
parent 8b73c86796
commit 785f3f9393
20 changed files with 71 additions and 3 deletions
Regular → Executable
+44 -3
View File
@@ -1,8 +1,11 @@
package lib
import (
"bytes"
"errors"
"fmt"
"os"
"path"
"path/filepath"
"strings"
@@ -41,9 +44,17 @@ func AppendToPdf(inputPdfFilePath string, inputXmlFilePath string, outputFilePat
),
)
err := api.AddAttachmentsFile(
inputPdfFilePath,
outputFilePath,
inputFile, err := os.Open(inputPdfFilePath)
if err != nil {
return err
}
defer inputFile.Close()
dest := bytes.Buffer{}
err = api.AddAttachments(
inputFile,
&dest,
[]string{inputXmlFilePath},
true,
model.NewDefaultConfiguration(),
@@ -52,5 +63,35 @@ func AppendToPdf(inputPdfFilePath string, inputXmlFilePath string, outputFilePat
return err
}
source := bytes.NewReader(dest.Bytes())
dest = bytes.Buffer{}
err = api.AddProperties(source, &dest, map[string]string{
"DocumentFileName": path.Base(inputXmlFilePath),
"DocumentType": "INVOICE",
"ConformanceLevel": "EN 16931",
"SchemasSchema": "Factur-X PDFA Extension Schema",
"SchemasPrefix": "fx",
"SchemasPropertyName": "DocumentFileName",
"SchemasPropertyValueType": "Text",
"SchemasPropertyCategory": "external",
"SchemasPropertyDescription": "The name of the embedded XML document",
}, model.NewDefaultConfiguration())
if err != nil {
return err
}
var outputFile *os.File
outputFile, err = os.Create(outputFilePath)
if err != nil {
return err
}
defer outputFile.Close()
_, err = outputFile.Write(dest.Bytes())
if err != nil {
return err
}
return nil
}
Regular → Executable
View File
Regular → Executable
View File