Need some help. I’m loading up a document from a dotx file that has some styles in it. I’m able to access the style and when I debug I can confirm the style has the properties I expect it to but when the document is rendered, it doesn’t have that style applied. Here is a code except:
LoadOptions options = new LoadOptions();
options.LoadFormat = LoadFormat.Dotx;
_document = new Aspose.Words.Document(HttpContext.Current.Server.MapPath("~/Template.dotx"), options);
_documentBuilder = new Aspose.Words.DocumentBuilder(_document);
Aspose.Words.Style h2Style = Document.Styles["Organization Name"];
h2Style.Font.Bold = Document.Styles["Organization Name"].Font.Bold;
h2Style.Font.Size = Document.Styles["Organization Name"].Font.Size;
h2Style.Font.Color = Document.Styles["Organization Name"].Font.Color;
h2Style.Font.Italic = Document.Styles["Organization Name"].Font.Italic;
h2Style.ParagraphFormat.SpaceBefore = Document.Styles["Organization Name"].ParagraphFormat.SpaceBefore;
h2Style.ParagraphFormat.SpaceAfter = Document.Styles["Organization Name"].ParagraphFormat.SpaceAfter;
_documentBuilder.ParagraphFormat.Style = h2Style;
_documentBuilder.Writeln("OrganizationName");
That should have pumped out a line with red font, italics, and bold but it does not. Also, when I export/download the document created above I see all my style names but they don’t have any of the correct style info. Additionally, when I try explicitly try to set a style like this (similar to above), it does not work:
Aspose.Words.Style h2Style = Document.Styles["Organization Name"];
h2Style.Font.Color = System.Drawing.Color.Fuchsia;
h2Style.Font.Italic = true;
but when I use a “built in” style it does work, note the use of StyleIdentifier enum:
Aspose.Words.Style h2Style = Document.Styles[Aspose.Words.StyleIdentifier.Heading2];
h2Style.Font.Color = System.Drawing.Color.Fuchsia;
h2Style.Font.Italic = true;
Thanks,
G