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

Free Support Forum - aspose.com

Word 2007 Theme fonts support

Hello,

We have some problems regarding the use of Word 2007 Theme fonts using the latest version Aspose.Words (v 11.5.0.0):

1. reading the font name always returns “Times New Roman”:

var d = new Document(@“Doc.docx”);

// get font names
foreach (Run run in d.GetChildNodes(NodeType.Run, true))
Console.WriteLine(run.Font.Name);


2. setting the font will not be reflected in the save output:

// set font names
foreach (Run run in d.GetChildNodes(NodeType.Run, true))
run.Font.Name = “Arial”;

d.Save(@“ArialDoc.docx”);

Observing the output file (“ArialDoc.docx”) will notice that only the 1st paragraph has the Arial font set correctly, following paragraphs still have the original Theme fonts.



Thank you!
Bogdan Rusu,
IBM Romania.

Hi Bogdan,


Thanks for your inquiry.

To be able to gather the details of what fonts are present in a document, I would suggest you please read the following article:
http://www.aspose.com/docs/display/wordsnet/Aspose.Words.Fonts.FontInfoCollection.Contains+Method

Secondly, please note that when you specify a font via theme, MS WORD shows theme name in round brackets e.g. Calibri (Body); Aspose.Words preserves Themes, but you cannot get Themes properties. Your request has been linked to the appropriate issue (WORDSNET-3312) in our issue tracking system and you will be notified as soon as this feature is supported. Sorry for the inconvenience.

Moreover, I think, I can suggest you a very simple workaround of this issue. Since DOC format does not support MS Word 2007/2010 Themes, formatting specified in themes will be converted to direct formatting upon saving DOCX to DOC format. So as a workaround, you can save your DOCX document as DOC, then open DOC file and then get font from this document as follows:

Document docx = new Document(@"C:\test\Doc.docx ");

MemoryStream docStream = new MemoryStream();
docx.Save(docStream, SaveFormat.Doc);

Document doc = new Document(docStream);

NodeCollection runs = doc.GetChildNodes(NodeType.Run, true);
foreach (Run run in runs)
{
Console.WriteLine(run.Font.Name);
}

I hope, this will help.

Best Regards,

Hello,

Thank you for the response.

What we are looking for is an easy way to Get/Set the font for a specific Run (see my original post) not to get all the fonts in a Document, as suggested.

Unfortunately the workaround provided does not fit our needs because:

  • it leads to more overhead (opening DOCX -> saving -> opening to DOC) in terms in memory usage and processing power.
  • saving to an older document version can introduce loss of formatting problems.

Bogdan Rusu,
IBM Romania.

Hi Bogdan,


Thanks for the additional information;
Bogdan:
What we are looking for is an easy way to Get/Set the font for a specific Run (see my original post) not to get all the fonts in a Document, as suggested.
I think, you can easily find a particular word or a phrase in a document using Aspose.Words and change the Font of that particular Run. Please read the following article for more information on how to achieve this:
http://www.aspose.com/docs/display/wordsnet/How+to++Find+and+Highlight+Text

Secondly, yes you’re right; but, unfortunately I can’t suggest you any other work around since Aspose.Words currently doesn’t publicly expose Theme’s properties. Rest assured, we will keep you informed of any developments and let you know via this forum thread once Theme’s information is exposed.

I apologise for any inconvenience.

Best Regards,

Hi,

Thank you for the response, we are waiting for the fixed version.

Bogdan Rusu,
IBM Romania.

Hi
Bogdan,


Thank you for your understanding. We will keep you informed of the status of this feature and let you know once it is available.

Best Regards,

Hi Bogdan,


Thank you for contacting me via email. I have verified the status of WORDSNET-3312 from our issue tracking system and regret to share with you that the implementation of this new feature (‘Consider exposing theme’s information’) has been postponed till a later date. I am afraid, we cannot push it into production right now because there are many other important issues we have to work on. Rest assured, we will inform you as soon as this issue is resolved. We apologize for the inconvenience.

Best regards,

Hi,

We are developing a tool for generating documents using Aspose.Word 13.2.0. We need to apply a specific theme to various documents, based on a common Word template, which requires modifying the original theme from the template. We were wandering if WORDSNET-3312 has been resolved. Does Apose.Word now support theme modifications?

Thanks and have a nice day!

Hi Emeline,

Thanks for your inquiry.

Unfortunately, Aspose.Words still does not provide an ability to get themes information. We will consider exposing themes in public API in one of future versions. We will let you know once this functionality is available. We apologize for any inconvenience.

Best regards,

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