Created
November 23, 2023 14:17
-
-
Save bjoerntx/ab008581394aa654487e690c73bf5d6f 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
public IActionResult Merge(string id) | |
{ | |
// url encoded | |
id = id.Replace("%2F", "/"); | |
var templateData = Storage.GetTemplate(id); | |
using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl()) | |
{ | |
tx.Create(); | |
tx.Load(Convert.FromBase64String(templateData), TXTextControl.BinaryStreamType.InternalUnicodeFormat); | |
using (MailMerge mailMerge = new MailMerge()) | |
{ | |
mailMerge.TextComponent = tx; | |
mailMerge.MergeJsonData(InvoiceData.GetDummyInvoiceData()); | |
} | |
tx.Save(out byte[] data, TXTextControl.BinaryStreamType.AdobePDF); | |
// return pdf document | |
return File(data, "application/pdf", "document.pdf"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment