Products Technologies Demo Docs Blog Support Company

Bringing MailMerge Power to Markdown: Fluid Placeholders in TX Text Control in C#

The latest beta version of the TX Text Control Markdown NuGet package introduces support for fluid placeholders, also known as Mustache or Handlebars syntax. This powerful feature enables developers to create dynamic documents by integrating mail merge capabilities directly into Markdown templates. In this blog post, we will explore how to use fluid placeholders with TX Text Control in C#.

Bringing MailMerge Power to Markdown: Fluid Placeholders in TX Text Control in C#

The third beta release of the TX Text Control Markdown NuGet package now supports fluid placeholders, also known as Mustache or Handlebars syntax.

This enhancement integrates the full capabilities of the MailMerge component into Markdown files, allowing developers to create dynamic templates with placeholders that automatically convert to merge fields and blocks.

Fluid Placeholders → Merge Fields

When loading Markdown content, the parser automatically detects placeholders such as {{ customer.name }} or loops like {{#foreach Items}} and converts them into TX Text Control merge fields and merge blocks. Now, just like with DOCX templates in MailMerge, you can merge data from JSON or XML directly into Markdown templates.

Example: Creating a Markdown Template with Placeholders

Here is an example of a Markdown template that uses fluid placeholders for a simple invoice:

# Markdown Parser Demo

This file shows the capabilities of the Markdown parser with Text Control Merge Fields.

---

## Merge Fields

**{{ customer.name }}**, {{ customer.company }}

Invoice #: *{{ invoiceNumber }}*

### Repeating Items:

{{#foreach Items}}{{ Name }}: {{ Quantity }} x {{ Price }}
{{/foreach Items}}

### A Table with Repeating Merge Blocks:

| Item    | Qty | Price |
|---------|----:|------:|
|{{#foreach Items}}{{ Name }}|{{ Quantity }}|{{ Price }}{{/foreach Items}}|
| **Total** |  1  | **{{ subtotal }}** |

Once this document has loaded, the placeholders will be replaced with the corresponding merge fields and blocks.

Placeholder Import

As you can see, merge fields with formatting, such as bold, and repeating blocks (highlighted in red), are imported.

Merging Data into the Template

The following JSON structure can be used to merge data into the template:

[{
    "invoiceNumber": "INV-2025-001",
    "date": "2025-10-17",
    "dueDate": "2025-10-31",
    "customer": {
      "name": "John Doe",
      "company": "Acme Corporation",
      "address": "123 Business St, Springfield, USA",
      "email": "john.doe@acme.com"
    },
    "items": [
      {
        "name": "TX Text Control .NET Server License",
        "quantity": 2,
        "price": 1299.00
      },
      {
        "name": "DS Server Enterprise Subscription",
        "quantity": 1,
        "price": 3499.00
      },
      {
        "name": "Support & Maintenance (1 Year)",
        "quantity": 1,
        "price": 599.00
      }
    ],
    "subtotal": 6696.00,
    "tax": 401.76,
    "total": 7097.76,
    "currency": "USD",
    "notes": "Thank you for your business! Payment due within 14 days."
  }
]

The following code uses the MailMerge component to merge data into the template:

using System.IO;
using TXTextControl;
using TXTextControl.DocumentServer;
using TXTextControl.Markdown;

using var tx = new ServerTextControl();
tx.Create();

string md = File.ReadAllText("sample.md");
string jsonData = File.ReadAllText("data.json");

// Load Markdown, then merge JSON data
tx.LoadMarkdown(md);

using var mailMerge = new MailMerge { TextComponent = tx, RemoveEmptyBlocks = true };
mailMerge.MergeJsonData(jsonData);

// Save as PDF
tx.Save("results.pdf", StreamType.AdobePDF);

After merging, the document is exported as a PDF, as shown in the following screenshot:

Merged PDF Document

Exporting the Results to Markdown

Exporting the resulting document to Markdown will give you the merged content and clean tables generated from the repeating blocks.

# Markdown Parser Demo

This file shows the capabilities of the Markdown parser with Text Control Merge Fields.

---

## Merge Fields

**John Doe**, Acme Corporation

Invoice \#: *INV\-2025\-001*

### Repeating Items:

TX Text Control .NET Server License: 2 x 1299

DS Server Enterprise Subscription: 1 x 3499

Support & Maintenance \(1 Year\): 1 x 599

### A Table with Repeating Merge Blocks:

| Item | Qty | Price |
| ----- | ----: | ----: |
| TX Text Control .NET Server License | 2 | 1299 |
| DS Server Enterprise Subscription | 1 | 3499 |
| Support & Maintenance (1 Year) | 1 | 599 |
| **Total** | 1 | **6696** |

The preview shows the merged content and clean tables generated from the repeating blocks.

Merged Markdown Document

Conclusion

The TX Text Control Markdown NuGet package's addition of fluid placeholder support significantly enhances the ability to create dynamic documents. Leveraging MailMerge capabilities directly within Markdown templates allows developers to streamline their document generation processes and easily create personalized content.

We encourage you to try out this new feature in the latest beta release and see how it can meet your document generation needs.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETASP.NET CoreMarkdown

Convert Markdown to PDF in a Console Application on Linux and Windows

Learn how to convert Markdown files to PDF in a console application on Linux and Windows using TX Text Control .NET Server for ASP.NET. This tutorial provides step-by-step instructions and code…


ASP.NETASP.NET CoreDOCX

DOCX Meets Markdown: Preparing Enterprise Documents for AI

Discover why Markdown is a game-changer for document creation in the age of AI. Explore how this lightweight markup language can enhance collaboration, version control, and integration with AI…


ASP.NETASP.NET CoreDOCX

Converting MS Word (*.docx) to Markdown (*.md) in .NET C#

Learn how to convert MS Word documents (*.docx) to Markdown files (*.md) in .NET C# using the TX Text Control .NET Server for ASP.NET. This tutorial provides a step-by-step guide to implement the…


ASP.NETASP.NET CoreMarkdown

Introducing TXTextControl.Markdown.Core: Import and Export Markdown in TX…

We are happy to announce the release of TXTextControl.Markdown.Core, a powerful new component that enables seamless import and export of Markdown files in TX Text Control. This addition enhances…


ASP.NETASP.NET CorePDF/UA

PDF/UA vs. PDF/A-3a: Which Format Should You Use for Your Business Application?

In this blog post, we will explore the differences between PDF/UA and PDF/A-3a, helping you choose the right format for your business needs. We will discuss the key features, benefits, and use…