Hi,
I'm trying to make linked style or character style in spire doc but I can't manage on how to do it.
Can you help me ?
Have a nice week
Document doc = new Document();
//Add a section
Section section = doc.AddSection();
//Add a paragraph
Paragraph para = section.AddParagraph();
CharacterFormat cf1 = new CharacterFormat(doc);
cf1.FontName = "Calibri";
cf1.FontSize = 16f;
cf1.TextColor = Color.Blue;
cf1.Bold = true;
cf1.UnderlineStyle = UnderlineStyle.Single;
//Add a text range 1 and set its style
TextRange range = para.AppendText("Spire.Doc for .NET ");
range.ApplyCharacterFormat(cf1);
//Add a text range 2 and set its style
CharacterFormat cf2= new CharacterFormat(doc);
cf2.FontName = "Calibri";
cf2.FontSize = 15f;
range = para.AppendText("is a professional Word .NET library");
range.ApplyCharacterFormat(cf2);
//Save the Word document
string output = "MultiStylesInAParagraph_out.docx";
doc.SaveToFile(output, FileFormat.Docx2013);
Document doc = new Document();
Section section = doc.AddSection();
Paragraph para = section.AddParagraph();
//Add style 1 and set its style type to CharacterStyle
Style ps1 = Style.CreateBuiltinStyle(BuiltinStyle.Normal, StyleType.CharacterStyle, doc) as Style;
ps1.Name = "Style1";
ps1.CharacterFormat.FontName = "Calibri";
ps1.CharacterFormat.FontSize = 22f;
ps1.CharacterFormat.Bold = true;
ps1.CharacterFormat.UnderlineStyle = UnderlineStyle.Single;
doc.Styles.Add(ps1);
//Add a text range 1 and set its style
TextRange range = para.AppendText("Spire.Doc for .NET ");
range.ApplyCharacterFormat(ps1.CharacterFormat);
//Add style 2 and set its style type to CharacterStyle
Style ps2 = Style.CreateBuiltinStyle(BuiltinStyle.Normal, StyleType.CharacterStyle, doc) as Style;
ps2.Name = "Style2";
ps2.CharacterFormat.FontName = "Calibri";
ps2.CharacterFormat.FontSize = 15f;
ps2.CharacterFormat.Italic = true;
doc.Styles.Add(ps2);
//Add a text range 2 and set its style
range = para.AppendText("is a professional Word .NET library");
range.ApplyCharacterFormat(ps2.CharacterFormat);
//Save the Word document
string output = "MultiStylesInAParagraph_out.docx";
doc.SaveToFile(output, FileFormat.Docx2013);