Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created July 25, 2024 10:13
Show Gist options
  • Save bjoerntx/fdf76a339eb70a50d8eeb6ffe5a8326c to your computer and use it in GitHub Desktop.
Save bjoerntx/fdf76a339eb70a50d8eeb6ffe5a8326c to your computer and use it in GitHub Desktop.
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