Free Support Forum - aspose.com

Styles not being applied correctly

In the attached document, on the second row of the main body table, the styles are not being applied correctly to the heading "Energy Regulatory Group advises on:". It should be bold like the one above. When I do a reveal formatting, it indicates the correct style is applied, but it is not bolding as it should. I'm using version 3.5. Please advise on why the style is not being applied correctly.

Thanks.

It seems that style applied to paragraph overlays the formatting setting of the runs of text inside the pargraph which results in such behavior. It is inconsistent with how MS Word applies the styles.

I have logged this to our defect base as Issue #881. We will try to fix it in the next release.

Meanwhile you can use the following workaround:

foreach(Run run in paragraph.Runs)

{

run.Font.ClearFormatting();

}

paragraph.ParagraphFormat.StyleName = "O PD Sidebar Heading PG1";

Thanks for reporting. But I would like to leave this behaviour without changes for the time being. The issue remains open on our task list, we might address it in the future.

I’ve discovered that the above work around removes the + that appears in MSWord, but when applying more complex styles that contain paragraph borders and shading for example, the borders and styles do not appear when the document is opened in MSWord.

The work around I have used is after applying the StyleName to the ParagraphFormat and Font objects then I need to manually (in code) transfer the style attributes I want into the DocBuilder.ParagraphFormat from the Document.Styles().ParagraphFormat object. A bit cumberson, but it works.