User-assigned delegate method that is called after HTMLToWord inserts an Element into the Word document. The user may implement code to perform additional formatting or post-processing on the Element inserted into the document. If this delegate is not set, HTMLToWord simply continues processing.

<table class="wysiwyg-macro" data-macro-name="unmigrated-wiki-markup" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e3VubWlncmF0ZWQtd2lraS1tYXJrdXB9&amp;locale=en_GB&amp;version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>
 public FormatElementDelegate FormatDelegate{ get; set; }
</pre></td></tr></table>
<p>Public Property FormatDelegate() As FormatElementDelegate</p>

 void MyFormatter(Element insertedElement, XmlNode node)
 {
      string nodeName = node.Name.ToLower();
 
      if (nodeName.Equals("ul"))
      {
           //--- First, cast the WordWriter Element object (passed in as a parameter to this method)
           //--- to a WordWriter List object.
           List theList = (List)insertedElement;

           //--- We want bulleted lists to have 1 line of spacing above and below to offset them
           //--- from the text.  This mimics the behavior of most HTML renderers.
 
           //--- Get the font size used in the list.  We'll use that value to determine
           //--- the appropriate line spacing gap.
           double fontSize = theList.GetEntry(0).Style.Font.FontSize;
           theList.GetEntry(0).Formatting.SpaceBefore = TwipsConverter.FromPoints(fontSize);
           theList.GetEntry(theList.NumEntries - 1).Formatting.SpaceAfter =
                TwipsConverter.FromPoints(fontSize);
      }   
 }


 //--- Create an HTMLToWord instance.
 HTMLToWord h2w = new HTMLToWord();
  
 //--- Tell HTMLToWord that it should call our "MyFormatter" delegate method 
 //--- whenever an Element is inserted into the Word document.
 h2w.FormatDelegate = new HTMLToWord.FormatElementDelegate(MyFormatter);

 Sub MyFormatter(Element insertedElement, XmlNode node)
      Dim nodeName As String = node.Name.ToLower()

      If nodeName.Equals("ul") Then
           '--- First, cast the WordWriter Element object (passed in as a parameter to this method)
           '--- to a WordWriter List object.
           Dim theList As List = insertedElement

           '--- We want bulleted lists to have 1 line of spacing above and below to offset them
           '--- from the text.  This mimics the behavior of most HTML renderers.
 
           '--- Get the font size used in the list.  We'll use that value to determine
           '--- the appropriate line spacing gap.
           Dim fontSize As Double = theList.GetEntry(0).Style.Font.FontSize
           theList.GetEntry(0).Formatting.SpaceBefore = TwipsConverter.FromPoints(fontSize)
           theList.GetEntry(theList.NumEntries - 1).Formatting.SpaceAfter = _
                TwipsConverter.FromPoints(fontSize)
      End If   
 End Sub



 '--- Create an HTMLToWord instance.
 Dim h2w As New HTMLToWord()
  
 '--- Tell HTMLToWord that it should call our "MyFormatter" delegate method 
 '--- whenever an Element is inserted into the Word document.
 h2w.FormatDelegate = New HTMLToWord.FormatElementDelegate(AddressOf MyFormatter)