Aspose Word style for Header is different from Word'd default header style

Hello Aspose team,

The header styles that Aspose word add to the document is different from default style provided by Word document. Should be as per default provided by Word document.

For example :

  1. Below image shows the header style in Word document created manually.
    image.png (14.1 KB)

  2. Below image shows the header style in document created by Aspose Word
    image.png (14.4 KB)

Observer that in document created by Aspose the header 2,5 & 8 are italic but in manually created word document its italic in 4,7 & 9th header. Similar changes for other properties like font family, size and bold.

Style is set using code :
docBuilder.getParagraphFormat().setStyleName(styleName);

Regards,
Zeeshan Khan
IBM Engineering LifeCycle Optimization - Publishing

@Zeeshan_Noor_Khan,

Please try using the following code:

Document doc = new Document();
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2016);

DocumentBuilder builder = new DocumentBuilder(doc);

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
builder.writeln("Heading");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_3);
builder.writeln("Heading");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_4);
builder.writeln("Heading");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_5);
builder.writeln("Heading");

builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_6);
builder.writeln("Heading");

doc.save("E:\\Temp\\awjava-19.8.docx"); 

Hope, this helps.