We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Font name incorrect in doc.Styles?

I'm trying to retrieve the name of the font used in a style, and I find that I'm getting "Times New Roman" when I expect "Calibri" based on the style I used when authoring the document in Word 2007.

Below is an example of the code I'm using, and I have attached the document. Can you explain what I should do?

Thanks,

Steve

namespace TestAspose
{
class Program
{
static void Main(string[] args)
{
Document doc = new Document("SimpleStyles.docx");
Console.WriteLine(doc.Styles["Title"].Font.Name);
}
}
}

Hi Steve,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. This occurs because font is specified via Word 2007 Theme. When font is specified via theme MS Word shows Theme’s name in round brackets (for example “Calibri(body)”). Aspose.Words preserves Themes, but you cannot get Themes properties.

I think, I can suggest 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.

Hope this helps.

Best regards,

Thanks for your reply. Could you consider this a bug? We use Aspose for a general format converting program, so we have no control over how the user saves the document (your suggested workaround). We need a way to get the font face (and other attributes) that is used in the named style that is applied to each paragraph in the document.

I see that this does work for styles saved in Word 2000, whether the styles were applied directly or applied to a them.

Thanks,

Steve

One more thing to note: in the document I uploaded (SimpleStyles.docx) I wasn't aware that I was using a Theme. I simply used the Word 2007 Home tab's Styles panel to select styles from the Normal template and apply them to the various pargraphs.

Steve

Hi Steve,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. We will consider adding an ability to get information from Themes in the future. Your request has been linked to the appropriate issue. I will notify you as soon as this feature is available.

Best regards,

Hi,



I’d like to add my vote to this. I can reproduce this as simply as running Office 2008 for Mac OS X, selecting “File->New” and typing “hello world” in a new document - I don’t need to format anything, select any styles or themes, or anything other than typing the text and then saving. The default font is “Calibri (body)” which translates to “Times New Roman” in Aspose.Words. This is severely crippling as we need our product to deliver output in the same font as the input document. We don’t necessarily need to preserve the theme, but to at least get the correct font out would resolve the problem for us.



Regards,

Mark.

Hi Mark,

Thanks for your vote. You will be notified as soon as this feature is available.

Best regards,

The issues you have found earlier (filed as 15886) have been fixed in this update.


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

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.
(10)