StyleIdentifier.Heading1 is not correctly formated (written) to document

See attachments, i’ create a compleatly new document.

Now i set Font and Size, write some text (this text is correct formated).

Now i used StyleIdentifier.Heading1, write some text, this is wrong formated (not like word formated heading1).

Please help. Thanks

Hi Bernhard,

Please try using the following code:

var builder = new DocumentBuilder(); 
// Font settings, for some text i want to write
builder.Font.Name = "Tahoma";
builder.Font.Size = 12;
// Some text
builder.Writeln("blalblalballbal ... blbalbalblalba");
builder.Writeln("blalblalballbal ... blbalbalblalba");
builder.Writeln("blalblalballbal ... blbalbalblalba");
builder.Writeln("blalblalballbal ... blbalbalblalba");
builder.InsertBreak(BreakType.ParagraphBreak);
builder.InsertBreak(BreakType.ParagraphBreak);
builder.InsertBreak(BreakType.ParagraphBreak);
builder.Font.ClearFormatting();
// Set StyleIdentifier Heading1
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;
// write heading 1 text
builder.Writeln("Heading1 - Arial - 16pt");
// Switch back to "normal"
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Normal;
// Some other text, i want to wirte into Tahoma
builder.Writeln("some text ... with Font Tahoma");
// Some other text, i want to wirte into Arial and other Size 14;
builder.Font.Name = "Arial";
builder.Font.Size = 14;
builder.Writeln("some text ... with Font Tahoma");
builder.Document.Save(MyDir + @"16.7.0.docx");

Best regards,

Thank you very much, you should add this “function” to your example.

But, thanks for your prompt help!

Hi Bernhard,

The description of “Font.ClearFormatting()” is already mentioned in online api reference:
https://reference.aspose.com/words/net/aspose.words/font/clearformatting/

Best regards,