feat: added additional meta data attributes
This commit is contained in:
Regular → Executable
+44
-3
@@ -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
Regular → Executable
Reference in New Issue
Block a user