Hi,
we are creating list programmatically and dynamically (based on html input - but we cannot use convert() method to convert from html to word as it does not suit our needs)
i am testing on following list:
<ul style=“color: red;”>
<li>Coffee
<li style=“color: blue;border: 1pt solid red”>Tea
<li>Milk
</ul>
we are building it like this:
Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.ListFormat.ApplyNumberDefault(); builder.Font.Color = Color.Red; builder.Write("jeden"); builder.InsertParagraph(); builder.ParagraphFormat.ClearFormatting(); builder.Font.ClearFormatting(); builder.Font.Color = Color.Blue; builder.ParagraphFormat.Borders.Color = Color.Red; builder.ParagraphFormat.Borders.LineStyle = LineStyle.Single; builder.ParagraphFormat.Borders.LineWidth = 1; builder.Write("dwa"); builder.InsertParagraph(); builder.ParagraphFormat.ClearFormatting(); builder.Font.ClearFormatting(); builder.Font.Color = Color.Red; builder.Write("trzy"); builder.InsertParagraph(); builder.ListFormat.RemoveNumbers(); doc.Save(@"OutputFiles\testText.docx");
Unfortunatelly after applying paragraphFormat.ClearFormatting() we are loosing all information about list level and type.
if we don’t clear formatting, in cases as above we keep the border formatting which is not intended.
Please note that the above is just an example of many possible combinations we could get and we can’t solve each case separately. instead we need some other way of either keeping info about list when performing paragrafFormat clean OR a way to re-apply list info to continue adding list items with correct numbering/on correct level
Thanks
Aga