Created
July 25, 2024 10:13
-
-
Save bjoerntx/fdf76a339eb70a50d8eeb6ffe5a8326c 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("rechnung_206_4267_zugferdaddon.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