How can i use default template

i build a empty document with some headings, but when i open the document, i found some of heading with different style between the word’s default style.

for example, the Heading2 style is italic, but in word default does not have talic style. my code is below:

Document doc = new Document();
doc.AttachedTemplate = "";
DocumentBuilder builder = new DocumentBuilder(doc);
Console.WriteLine("Template: {0}", doc.BuiltInDocumentProperties.Template);

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

builder.Writeln("Heading 1");

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

builder.Writeln("Heading 1.1");
builder.Writeln("Heading 1.2");

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

builder.Writeln("Heading 2");
builder.Writeln("Heading 3");

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

builder.Writeln("Heading 3.1");

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;

builder.Writeln("Heading 3.1.1");
builder.Writeln("Heading 3.1.2");
builder.Writeln("Heading 3.1.3");

builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

builder.Writeln("Heading 3.2");
builder.Writeln("Heading 3.3");

i tried using “Normal.dotm”:

var templateBuilder = new DocumentBuilder(new Document(defaultTemplateFile));

but the result style is changing to another way which like the resource file “AllStyles2007.docx” in Aspose.Words assambly.

how can i use the exactly word2010 default style?

i use 13.10~13.12, the result is same.

Hi Pyntia,

Thanks for your inquiry.

If the document loaded in Aspose.Words DOM is created using Microsoft Word 2003 or using lower versions, Aspose.Words will use 2003 styles. Similarly, if it is created using Microsoft Word 2007, Aspose.Words will use 2007 styles. However, you can create an empty DOCX using Microsoft Word 2010 and use it as a start document as follows:

Document doc = new Document(@"C:\Temp\Blank2010.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;
builder.Writeln("Heading 2");
doc.Save(@"C:\Temp\out.docx");

Currently, Aspose.Words uses “Blank.doc” as a start document in case you create an empty document using the following constructor:

Document doc = new Document();

The “Blank.doc” is embedded in Aspose.Words API and was created using Microsoft Word 2003 that is why Aspose.Words formats the Heading2 text in output documents with 2003 styles. We will support different Microsoft Word versions for a blank document in future though. Your request has been linked to the appropriate issue (WORDSNET-5561) and you will be notified as soon as it is resolved. Sorry for the inconvenience.

Best regards,

hi, Awais

thank you explained so detail
i got it now