Thanks Alexey,
I am almost there. I used a slightly modified approach to yours. I wanted the inner lists from the html to be inserted at the next ListLevelNumber. Follows shows my solution.
My current (and hopefully last List question) is in my inserted html after I insert a list, the text afterwards see bolded text("More Text at the end") appears as a new item in the list rather than continuing the text prior to the insertion of the list.
I also notice the same affect when there is a table in the html.
Any ideas on how to acheive? (attached is the desired result)
Thanks for your help!
private void btnTest_Click(object sender, EventArgs e)
{
Document doc = new Document();
List list = doc.Lists.Add(ListTemplate.OutlineHeadingsLegal);
ListLevel level1 = list.ListLevels[0];
level1.NumberFormat = "\x0000.0";
level1.NumberPosition = 0;
level1.TabPosition = ConvertUtil.InchToPoint(0.45d);
level1.TextPosition = ConvertUtil.InchToPoint(0.45d);
ListLevel level2 = list.ListLevels[1];
level2.NumberStyle = NumberStyle.LeadingZero;
level2.NumberFormat = "\x0000.\x0001";
level2.NumberPosition = ConvertUtil.InchToPoint(0d);
level2.TabPosition = ConvertUtil.InchToPoint(0.45d);
level2.TextPosition = ConvertUtil.InchToPoint(0.45d);
ListLevel level3 = list.ListLevels[2];
level3.NumberStyle = NumberStyle.LeadingZero;
level3.NumberFormat = "\x0000.\x0001.\x0002";
level3.NumberPosition = ConvertUtil.InchToPoint(0.45d);
level3.TabPosition = ConvertUtil.InchToPoint(1.05);
level3.TextPosition = ConvertUtil.InchToPoint(1.05);
ListLevel level4 = list.ListLevels[3];
level4.NumberStyle = NumberStyle.LowercaseRoman;
level4.NumberFormat = "(\x0003)";
level4.NumberPosition = ConvertUtil.InchToPoint(1.05d);
level4.TabPosition = ConvertUtil.InchToPoint(1.65);
level4.TextPosition = ConvertUtil.InchToPoint(1.65);
ListLevel level5 = list.ListLevels[4];
level5.NumberStyle = NumberStyle.LowercaseLetter;
level5.NumberFormat = "(\x0004)";
level5.NumberPosition = ConvertUtil.InchToPoint(1.65d);
level5.TabPosition = ConvertUtil.InchToPoint(2.25);
level5.TextPosition = ConvertUtil.InchToPoint(2.25);
for (int i = 5; i < list.ListLevels.Count; i++)
{
ListLevel level = list.ListLevels[i];
level.NumberPosition = ConvertUtil.InchToPoint(1.05d);
level.TabPosition = ConvertUtil.InchToPoint(1.65);
level.TextPosition = ConvertUtil.InchToPoint(1.65);
}
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ListFormat.List = list;
builder.Writeln("The quick brown fox...");
builder.Writeln("The quick brown fox...");
builder.ListFormat.ListIndent();
builder.Writeln("jumped over the lazy dog.");
builder.ListFormat.ListIndent();
Node startingNode = builder.CurrentParagraph as Node;
builder.InsertHtml("Testing instering HTML adsf adsf adsf adsf adsfklajsdf klajsdf kljasdfkl jakl;sdfj kl;adsjf klajsdf klajsdfkl jasdf klja;sdf aklsd;fj klasdjf afewiajdsvm ioasdfklmnewf oipasdf kamnsdklfaiweojaweiorj aosdf aisdjfoaweriaewjio adsjf aidsjfoaewjioaejw ioadsfj oo
asfasd asdf adsf adsf asdf asdf asdf adsf asdf adsf adsf adsf asdf adsf adsfaadsf adsf ads
- Outer HTML List 1.
- Outer HTML List 2.
- Inner HTML List 1
- Inner HTML List 2
More Text at the end");
Node endingNode = builder.CurrentParagraph as Node;
Node node = endingNode;
while (node != startingNode)
{
ProcessNode(startingNode, node);
node = node.PreviousSibling;
}
ProcessNode(startingNode, node);
builder.ListFormat.List = list;
builder.ListFormat.ListIndent();
builder.Writeln("jumped over the lazy dog.");
builder.ListFormat.ListOutdent();
builder.Writeln("The quick brown fox...");
builder.ListFormat.RemoveNumbers();
builder.Document.Save("Lists.CreateCustomList Out.doc");
}
private static void ProcessNode(Node startingNode, Node node)
{
if (node is Paragraph)
{
Paragraph paragraph = node as Paragraph;
if (paragraph.IsListItem)
{
if (paragraph.ListFormat.List.ListId
!= (startingNode as Paragraph).ListFormat.List.ListId)
{
paragraph.ListFormat.List = (startingNode as Paragraph).ListFormat.List;
paragraph.ListFormat.ListLevelNumber = paragraph.ListFormat.ListLevelNumber + (startingNode as Paragraph).ListFormat.ListLevelNumber + 1;
}
}
}
}