I have inserted from a word file document into another one. But after inserting, list symbols couldn't keep original format
See attachment:
My code here:
public void InsertDocument(int position, string sourcefile,string destfile)
{
this.pos = position;
Document sourcedoc = new Document();
List list = new List();
list.ListFormat = ListFormat.GetMultiLevelBulletListFormat("");
sourcedoc.Load(DocFormat.Instance, sourcefile.Substring(0, sourcefile.Length - 4));
Document destdoc = new Document();
destdoc.Load(DocFormat.Instance, destfile.Substring(0, destfile.Length - 4));
for (int c = 0; c < sourcedoc.Elements.Count; c++)
{
TravelElement(sourcedoc.Elements[c], ref destdoc);
}
destdoc.Save(DocFormat.Instance, destfile);
}
private void TravelElement(TextElement element, ref Document outputDoc)
{
switch (element.ElementType)
{
case TextElementType.List:
List list = (List)element;
outputDoc.InsertList(pos,list);
pos += list.Text.Length;
break;
case TextElementType.ListLevel:
break;
case TextElementType.Paragraph:
Paragraph para = (Paragraph)element;
outputDoc.InsertParagraphCopy(pos,para);
pos += para.Text.Length;
break;
case TextElementType.Section:
Section section = (Section)element;
List<Object> paraList = new List<Object>();
foreach (Object p in section.Elements)
{
paraList.Add(p);
}
for (int i = 0; i < paraList.Count; i++)
{
TravelElement((TextElement)paraList[i], ref outputDoc);
}
break;
case TextElementType.Table:
Table table = (Table)element;
outputDoc.InsertTable(pos,table);
pos += table.Text.Length;
break;
default:
break;
}
}
