Hi! Toggling the italics-property in DocumentBuilder results in subsequent text that should be italic to be non-italic. I’ve verified this ni the latest version av Aspose Words .Net 14.5.
Consider the following code:
var aDoc = SetupDoc(); // incl licensing
aDoc.Sections.Clear();
DocumentBuilder builder = new DocumentBuilder(aDoc);
builder.ParagraphFormat.ClearFormatting();
builder.ParagraphFormat.StyleName = "Normal";
builder.Write("A line of text, w/ one word in: ");
builder.Italic = true;
builder.Write("italics");
builder.Italic = false;
builder.Writeln(" in it.");
builder.ParagraphFormat.ClearFormatting();
builder.ParagraphFormat.StyleName = "Heading 4";
builder.Writeln("Headline Heading 4 --> incl. italics - but becomes non-italics");
builder.ParagraphFormat.ClearFormatting();
builder.ParagraphFormat.StyleName = "Normal kursiv";
builder.Writeln("Regular text that uses style Normal italics and turns out to not use italics...");
That one word in italics will in fact be italics, but that Heading 4 that should also appear in italics appears as regular text. Removing that word italics and the properties will result in the proper behaviour for Heading 4.
Replacing the builder.Italic = true and such with:
builder.InsertHtml("<i>italics</i>");
Will solve it, but I would rather prefer to use the properties on documentbuilder…
Rgds, Patrik
PS. Attached is a PDF with the code as well as the output rendered from Word 2013.