feat: added xmp data

This commit is contained in:
2026-02-07 16:09:34 +01:00
parent b659359a79
commit 1196274498
17 changed files with 513 additions and 46 deletions
+73
View File
@@ -0,0 +1,73 @@
package lib
import (
xmpbase "github.com/trimmer-io/go-xmp/models/xmp_base"
"github.com/trimmer-io/go-xmp/xmp"
)
const (
FacturXNamespace = "Factur-X PDFA Erweiterungsschema"
FacturXUri = "urn:factur-x:pdfa:CrossIndustryDocument:invoice:1p0#"
FacturXPrefix = "fx:"
)
func addFacturXXmpData(data []byte) ([]byte, error) {
doc := &xmp.Document{}
err := xmp.Unmarshal(data, doc)
if err != nil {
return nil, err
}
// --- Register Factur-X namespace ---
ns := &xmp.Namespace{
Name: "fx",
URI: FacturXUri,
Factory: func(name string) xmp.Model {
return &xmpbase.XmpBase{}
},
}
xmp.Register(ns)
_, err = doc.MakeModel(ns)
if err != nil {
return nil, err
}
// --- Set Factur-X properties ---
err = doc.SetPath(xmp.PathValue{
Path: FacturXPrefix + "ConformanceLevel",
Namespace: FacturXUri,
Value: "EN 16931",
})
if err != nil {
return nil, err
}
err = doc.SetPath(xmp.PathValue{
Path: FacturXPrefix + "DocumentType",
Namespace: FacturXUri,
Value: "INVOICE",
})
if err != nil {
return nil, err
}
err = doc.SetPath(xmp.PathValue{
Path: FacturXPrefix + "DocumentFileName",
Namespace: FacturXUri,
Value: "factur-x.xml",
})
if err != nil {
return nil, err
}
err = doc.SetPath(xmp.PathValue{
Path: FacturXPrefix + "Version",
Namespace: FacturXUri,
Value: "1.0",
})
if err != nil {
return nil, err
}
return xmp.Marshal(doc)
}