Created
September 23, 2024 13:13
-
-
Save bjoerntx/b613de3bb721fdfcc1cf3cb118304831 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 System.Data; | |
using System.Text; | |
using TXTextControl.DocumentServer; | |
string xmlData = File.ReadAllText("data.xml"); | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) | |
{ | |
tx.Create(); | |
tx.Load("zugferd_template.tx", TXTextControl.StreamType.InternalUnicodeFormat); | |
MailMerge mailMerge = new MailMerge(); | |
mailMerge.TextComponent = tx; | |
// dataset from XML | |
DataSet ds = new DataSet(); | |
ds.ReadXml(new MemoryStream(Encoding.UTF8.GetBytes(xmlData))); | |
// merge data | |
mailMerge.Merge(ds.Tables["SupplyChainTradeTransaction"]); | |
// save as PDF | |
tx.Save("output.pdf", TXTextControl.StreamType.AdobePDF); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment