I think if you use css styles you are bound to fail.
htm2openxml tries to create word styles on the fly: eg. (just some random lines of code)
StartNumberingValue = new StartNumberingValue() { Val = 1 },
NumberingFormat = new NumberingFormat() { Val = NumberFormatValues.LowerLetter },
LevelIndex = 0,
LevelText = new LevelText() { Val = "%1." },
PreviousParagraphProperties = new PreviousParagraphProperties {Indentation = new Indentation() { Left = "420", Hanging = "360" }
prop.SpacingBetweenLines = new SpacingBetweenLines() { After = "0" };
prop.Indentation = new Indentation() { Hanging = "357", Left = (level * 357).ToString(CultureInfo.InvariantCulture) };
therefor fighting with the predefined word styles and messing with number styles and indentation, which are complicated enough to define correctly in word.
In the same concept as any HTML document ditch the inline styles and use use a predefined class in your stylesheet.css
word documents are much cleaner if you stop using the font and paragraph buttons and only use the predefined styles.
To solve this, need to use a predefined word list style (css class) and only manipulate the level of the paragraphs numbering properties.
I think this should work, add the commented section to my code above.
currentParagraph.InsertInProperties(prop => prop.ParagraphStyleId = new ParagraphStyleId() { Val = className });
/// Handle Numbering Levels
currentParagraph.InsertInProperties(prop =>
prop.NumberingProperties = new NumberingProperties
{
NumberingLevelReference = new NumberingLevelReference() { Val = level - 1 },
NumberingId = new NumberingId() { Val = numberingId }
});
///
break;
I think this should work, but you will still need to use the class in your <li class="MultilevelList">
I made a regex function to replace all my <li> :
cvHtml = RegexReplace(@"((?:<li.*?>))", @"<li class=""MultilevelList"" >", cvHtml);
private static string RegexReplace(string strRegex, string strReplace, string withInString)
{
Regex myRegex = new Regex(strRegex, RegexOptions.None);
string withLiClass = myRegex.Replace(withInString ?? "", strReplace);
return withLiClass;
}
Ive got to run now, but I think that will be enough to get around the levels and submit a useful patch.