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);
|