I’ve noticed that if I use a list, that if a Style is assigned to the next paragraph, it doesn’t apply correctly.
LeftIndent on the paragraphFormat is zero, but LeftIndent on the paragraphFormat.Style.ParagraphFormat.LeftIndent is not.
However, if I clear formatting and then apply a style, then it is applied correctly.
Our product is producing word documents from configuration, rather than hard-coding, so it’s not clear what impact ClearFormatting() will have on our system.
Is this expected behaviour (that the Style didn’t update the paragraph’s formatting?)
public static void Test()
{
var doc = new Aspose.Words.Document();
doc.CopyStylesFromTemplate(@"c:\temp\IndentedStyleTemplate.dotx");
var builder = new Aspose.Words.DocumentBuilder(doc);
var list = doc.Lists.Add(Aspose.Words.Lists.ListTemplate.NumberArabicDot);
builder.ListFormat.List = list;
builder.Writeln("List item 1");
builder.Writeln("List item 2");
builder.ListFormat.RemoveNumbers();
builder.Writeln("Setting style");
builder.CurrentParagraph.ParagraphFormat.Style = doc.Styles["SmallIndent"];
builder.Writeln("This line should be indented but it isn't");
builder.Writeln("");
builder.ParagraphFormat.ClearFormatting();
builder.Writeln("Setting style again");
builder.CurrentParagraph.ParagraphFormat.Style = doc.Styles["SmallIndent"];
builder.Writeln("This line should be indented");
doc.Save(@"c:\temp\Output.docx");
}
I was going to attach the template, but can’t seem to find the ‘attachments’ button. All SmallIndent is, is a paragraph style indented by a centimetre.