Setting the bold property on the font object of a document-wide style make it disappear in generated document


#1

Hello,

I want to define a paragraph style and use it to format a paragraph in the generated Word document. Here is the code I use:

Document Doc=new Document();

Doc.EnsureMinimum();

Style newStyle;

newStyle=Doc.Document.Styles.Add(StyleType.Paragraph, “testStyle”);

newStyle.Font.Name=“Arial”;

newStyle.BaseStyle=“Normal”;

//The following line makes the “testStyle” style disappear in the generated doc

//newStyle.Font.Bold=false;

newStyle.ParagraphFormat.Alignment=ParagraphAlignment.Right;

DocumentBuilder db=new DocumentBuilder(Doc);

db.ParagraphFormat.StyleName=“testStyle”;

db.Writeln(“test text”);

Doc.Save(@“c:\test.doc”);


When I uncomment the lines that sets the ‘bold’ property in the ‘font’ object of the ‘testStyle’ style object, and regenerate the document: the generated paragraph does not have any style defined, and none of the formatting I specified in the ‘testStyle’ style were applied.

Can you reproduce this ? If yes, is my code wrong ?

I use Word 2003 to view the generated documents (they are generated in the .doc format).
The same behavior occurs if I set the ‘Color’ property instead of the ‘Bold’ property (I did not try any other properties, but I guess this happens for all properties of the ‘Font’ object)


#2

Hi,

Thank you for considering Aspose.

Are you using the latest version of the component? Your code works just fine for me, the testStyle style does not disappear in the resulting document.


#3

Indeed, version 3.1.0.0 solved the problem. I previously used version 3.0.0.0.

Thank you for the quick response.