Skip to content

Instantly share code, notes, and snippets.

@bjoerntx
Created November 23, 2023 14:17
Show Gist options
  • Save bjoerntx/ab008581394aa654487e690c73bf5d6f to your computer and use it in GitHub Desktop.
Save bjoerntx/ab008581394aa654487e690c73bf5d6f to your computer and use it in GitHub Desktop.
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