Modifying style does not work as expected

Hello,

I’m trying to modify styles in an existing document that was created with Ms Word.
e.g. I try to change the font color with

var heading = document.Styles[StyleIdentifier.Heading1];
heading.Font.Color = Color.FromArgb(255, 50, 50, 50);

But after saving, the heading 1 is still with the old word default style. However when I check the
document with the debugger just before I save it, I can see that the font color is changed to the
new value.

I attached the document I try to modify styles.

Did I miss something in the API reference? Or is the behavior wrong?

Best Regards
Philipp

Hello
Thanks for your request. This occurs because in your document font color is defined in Theme. Unfortunately, Aspose.Words does not provide an ability to access Theme’s information. However, Themes are fully preserved upon processing.
As a workaround, you can convert your document to DOC and then get/set font color, because DOC format does not support Themes, and formatting defined in Themes is expanded into direct formatting.

Document doc = new Document("C:\\Temp\\Complex.WithToc.docx");
// Convert DOCX to DOC to fix the problem.
MemoryStream docStream = new MemoryStream();
doc.Save(docStream, SaveFormat.Doc);
// Open document from stream.
doc = new Document(docStream);
doc.Styles[StyleIdentifier.Heading1].Font.Color = Color.Red;
doc.Save("C:\\Temp\\out.docx");

Or you can try using DOC as output format.
Hope this helps.
Best regards,

Hi Alexey

Thanks for your suggestion. I will try them.

Are there plans to support the Theme feature in the near future (this year)?

Regards
Philipp

Hi
Thanks for your request. Unfortunately, at the moment we cannot provide you any reliable estimate regarding this issue. We will keep you informed regarding status of this issue and immediately let you know when it is resolved.
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 the previous issue has been resolved. Does Aspose.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.
(2)