Default font format

I am converting docx documents to html. Now I need to fetch the default (Normal) font format of a template document seperately from the content to use in the sites css.

My problem arises when I do the following:

Font font = doc.Styles["Default Paragraph Font"].Font; //Same for "Normal"

When I try to get the font name it gives me back “Times New Roman” when it should be “Century Gothic”.

Now the strange thing is that when I use the VS QuickWatch to enumerate the result view of my Aspose.Document variable the font gets updated (correctly).

I tried enumerating the document childnodes myself, adding new items, and lots of other desperate things. None worked.
Even if I enumerate the children and check their font I get “Times New Roman”. None of the runs seems to use “Century Gothic”.

I can however find the “Century Gothic”-font within the document’s FontInfos-list.
When I save the document the (style)font is correct (in MS Word). Even when creating a new document, copying the content (using keepSourceFormatting) Aspose returns “Times New Roman” and in generated MsWord-doc the font is correct."

I am using Aspose.Words 8.0, but when trying with the latest trial the same problem arises.


Thanks for your inquiry. I managed to reproduce this issue on my side. I have logged this issue in our bug tracking system. Your request has also been linked to the appropriate issue and you will be notified as soon as it is resolved. Sorry for inconvenience.

Hi Jonathan,

I think, I can propose you a very simple workaround of this issue. Since DOC format does not support MS Word 2007 Themes, formatting specified in themes is converting to direct formatting. So as a workaround, you can save your DOCX document as DOC, then open DOC file and then get font from this document.

// Open docx
Document docx = new Document("d:/test/myTemplate3.docx");
// Save it in doc format

// Open doc Word Document Document doc = new Document("d:/test/myTemplate3.doc");

foreach(var run in doc.GetChildNodes(NodeType.Run, true))
    Console.WriteLine(((Run) run).Text + " " + ((Run) run).Font.Name);

Hi Imran,

Thank you for your reply. Your post put me in the right direction. For future reference, this is how I solved it using your work around:

Document doc = new Document("template.docx");

string runText = doc.GetChildNodes(NodeType.Run, true).ToArray().Cast<Run>().First(run => run.Font.StyleName.Equals("Default Paragraph Font")).GetText();
MemoryStream strDoc = new MemoryStream();
doc.Save(strDoc,  SaveFormat .Doc);
doc =  new  Document (strDoc);

Aspose.Words.Font font = doc.GetChildNodes(NodeType.Run, true).ToArray().Cast<Run>().First(run => run.GetText().Equals(runText)).Font;

As you can see, I used Linq 2 times to get a run with the correct style.

Hi Jonathangrisez,
Thank you very much for your feedback. It is great to hear that your issue has been resolved. You are always welcome and please feel free to ask if you have any query in future.

We always welcome constructive response from our customers.

The issues you have found earlier (filed as WORDSNET-3312) have been fixed in this .NET update and this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.