Created
September 30, 2024 14:37
-
-
Save bjoerntx/12ac7bbc11dcd0444ff3c43741dbe49a 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; | |
using TXTextControl.DocumentServer; | |
using TXTextControl.DocumentServer.DataSources; | |
using (ServerTextControl tx = new ServerTextControl()) | |
{ | |
tx.Create(); | |
string jsonData = File.ReadAllText("tabledata.json"); | |
DataSourceManager dataSourceManager = new DataSourceManager(); | |
dataSourceManager.LoadJson(jsonData); | |
MergeBlockInfo mergeBlockInfo = new MergeBlockInfo("items"); | |
mergeBlockInfo.ColumnNames.Add("product"); | |
mergeBlockInfo.ColumnNames.Add("price"); | |
mergeBlockInfo.ColumnNames.Add("quantity"); | |
MergeBlockSettings mergeBlockSettings = new MergeBlockSettings(BlockTemplateType.TableRow, true); | |
dataSourceManager.InsertMergeBlock(tx, mergeBlockInfo, mergeBlockSettings); | |
MailMerge mailMerge = new MailMerge() | |
{ | |
TextComponent = tx | |
}; | |
mailMerge.MergeJsonData(jsonData); | |
// save the document as PDF | |
tx.Save("results.pdf", StreamType.AdobePDF); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment