Created
July 25, 2024 10:14
-
-
Save bjoerntx/1be303aee3e69cfd4ab1b95f0f90f41f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using TXTextControl; | |
SaveSettings saveSettings = new SaveSettings(); | |
var metaData = File.ReadAllText("metadata.xml"); | |
// byte array from the ZUGFeRD XML file | |
var zugferdXML = File.ReadAllBytes("yourzugferd.xml"); | |
// create a new embedded file | |
var zugferdInvoice = new EmbeddedFile( | |
"ZUGFeRD-invoice.xml", | |
zugferdXML, | |
metaData); | |
zugferdInvoice.Description = "ZUGFeRD-invoice"; | |
zugferdInvoice.Relationship = "Alternative"; | |
zugferdInvoice.MIMEType = "application/xml"; | |
zugferdInvoice.LastModificationDate = DateTime.Now; | |
// set the embedded files | |
saveSettings.EmbeddedFiles = new EmbeddedFile[] { zugferdInvoice }; | |
using (ServerTextControl tx = new ServerTextControl()) | |
{ | |
tx.Create(); | |
tx.Text = "Invoice"; | |
// export the PDF | |
tx.Save("invoice.pdf", StreamType.AdobePDFA, saveSettings); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment