WordDocument document = new WordDocument(@"..\..\charstyle.doc");
foreach (Entity ent in document.ChildEntities)
{
if (ent is WSection)
{
WSection section = ent as WSection;
foreach (WParagraph paragraph in section.Body.Paragraphs)
{
foreach (ParagraphItem item in paragraph.Items)
{
if (item.EntityType == EntityType.TextRange)
{
WTextRange range = item as WTextRange;
WCharacterFormat characterformat = range.CharacterFormat;
MessageBox.Show(characterformat.Bold.ToString());
MessageBox.Show(range.CharacterFormat.Bold.ToString ());
}
}
}
}
}
WordDocument document = new WordDocument(@"..\..\charstyle.doc");
foreach (Entity ent in document.ChildEntities)
{
if (ent is WSection)
{
WSection section = ent as WSection;
foreach (WParagraph paragraph in section.Body.Paragraphs)
{
foreach (ParagraphItem item in paragraph.Items)
{
if (item.EntityType == EntityType.TextRange)
{
WTextRange range = item as WTextRange;
WCharacterFormat characterformat = range.CharacterFormat;
MessageBox.Show(characterformat.Bold.ToString());
MessageBox.Show(range.CharacterFormat.Bold.ToString ());
}
}
}
}
}
IStyleCollection col = document.Styles;
foreach (Style st in col)
{
if (st.StyleType == StyleType.CharacterStyle)
{
WCharacterFormat ch = st.CharacterFormat;
//To change the style
//ch.TextBackgroundColor = Color.Red;
Console.WriteLine("Style Type = " + st.StyleType.ToString() + " Bold= " + ch.Bold.ToString() );
}
}
Here is the sample for both the methods:
http://www.syncfusion.com/uploads/redirect.aspx?file=Character_Style1_a40b4f6e.zip&team=support
Please have a look into the sample and could you please send us the modified one to reproduce the issue and to investigate further on this issue?
Best Regards,
Bhuvana
IStyleCollection col = document.Styles;
foreach (Style st in col)
{
if (st.StyleType == StyleType.CharacterStyle)
{
WCharacterFormat ch = st.CharacterFormat;
//To change the style
//ch.TextBackgroundColor = Color.Red;
Console.WriteLine("Style Type = " + st.StyleType.ToString() + " Bold= " + ch.Bold.ToString() );
}
}
Here is the sample for both the methods:
http://www.syncfusion.com/uploads/redirect.aspx?file=Character_Style1_a40b4f6e.zip&team=support
Please have a look into the sample and could you please send us the modified one to reproduce the issue and to investigate further on this issue?
Best Regards,
Bhuvana
WTextRange range = item as WTextRange;
WCharacterFormat characterformat = range.CharacterFormat;
Console.WriteLine("Text =" + range.Text);
Console.WriteLine("Bold= " + characterformat.Bold.ToString());