title: MailMerge if-statement with dynamic table inside
body: <p>I'm currently working on a MailMerge Word-docx. When we had the following, everything worked fine:
  <a href="https://i.stack.imgur.com/wXSmG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wXSmG.png" alt="enter image description here"></a></p>
  
  <p>And the result was:
  <a href="https://i.stack.imgur.com/ntoUF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ntoUF.png" alt="enter image description here"></a></p>
  
  <hr>
  
  <p>What we want is to not show this table if there aren't any Authorization-events, so I've changed it to the following:
  <a href="https://i.stack.imgur.com/U4mAq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/U4mAq.png" alt="enter image description here"></a></p>
  
  <p>With the following result:
  <a href="https://i.stack.imgur.com/p6brg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p6brg.png" alt="enter image description here"></a></p>
  
  <p>As you can see, the table is now empty, even though there are AuthorizationEvents. Is it possible to somehow use a dynamic table inside an <code>IF-MERGEFIELD</code>? Is this is a bug in Aspose's MailMerging, or I'm simply doing something wrong?</p>
  
  <p>PS: I know the MailMerge-synthax we use with the <code>{{Something}}</code> is less known than the <code>&lt;&lt;Something&gt;&gt;</code>, but they work the same. Just a heads-up since I had questions regarding the MailMerge-synthax in the past.</p>
  
  <hr>
  
  <p>Here is the .NET code (although I doubt it's relevant for my issue):</p>
  
  <pre><code>public class PrintDto
  {
      public PrintDto(OurObject ourObject, ProcessTimeline processTimeline)
      {
          ...
  
          AutorisatieEvents = GetAutorisatieEvents(processTimeline);
          HeeftAutorisatieEvents = AutorisatieEvents.Any();
      }
  
      ...
  
      public IList&lt;AutorisatieEventDto&gt; AutorisatieEvents { get; private set; }
      public bool HeeftAutorisatieEvents { get; private set; }
  }
  </code></pre>
  
  <p>AutorisatieEventDto:</p>
  
  <pre><code>public class AutorisatieEventDto
  {
      public string Happened { get; set; }
      public string Event { get; set; }
      public string Performer { get; set; }
      public string Opmerking { get; set; }
  }
  </code></pre>
  
  <p>MailMerging code:</p>
  
  <pre><code>public byte[] GenerateDocument(Stream template, DocumentDataSource dataSource)
  {
      var doc = new Document(template);
  
      doc.MailMerge.UseNonMergeFields = true;
      doc.MailMerge.CleanupOptions = MailMergeCleanupOptions.RemoveContainingFields |
                                     MailMergeCleanupOptions.RemoveUnusedFields |
                                     MailMergeCleanupOptions.RemoveUnusedRegions |
                                      MailMergeCleanupOptions.RemoveEmptyParagraphs;
  doc.ResourceLoadingCallback = new ImageLoadingHandler();
  
  // Support html MailMerge-fields
  doc.MailMerge.FieldMergingCallback = new HandleMergeFieldInsertHtml();
  
  doc.MailMerge.Execute(dataSource);
  doc.MailMerge.ExecuteWithRegions((IMailMergeDataSourceRoot) dataSource);
  
  doc.UpdateFields();
  
  using (var memoryStream = new MemoryStream())
  {
      doc.Save(memoryStream, SaveFormat.Pdf);
      return memoryStream.ToArray();
  }
  </code></pre>
  
  <p>Which is used in:</p>
  
  <pre><code>public byte[] CreatePrintAsBytes(PrintDto printData)
  {
      if (printData == null) throw new ArgumentNullException("printData");
  
      var path = Path.Combine(_templatePath, "printdto.docx");
  
      using (var fileStream = File.OpenRead(path))
      {
          var dataSource = new DocumentDataSource(printData);
          return DocumentConverter.GenerateDocument(fileStream, dataSource);
      }
  }
  </code></pre>
  
  <p>And displayed like this:</p>
  
  <pre><code>[HttpGet]
  public ActionResult Print(Guid id)
  {
      var ourObject = NhSession.GetByGuid&lt;OurObject&gt;(id);
      var processTimeline = GetProcessTimelineOfOurObject(ourObject);
      var printData = new PrintDto(ourObject, processTimeline);
  
      var documentAsByteArray = _documentService.CreatePrintAsBytes(printData);
  
      return File(documentAsByteArray, "application/pdf");
  }
  </code></pre>