using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Spire.Doc;
using Spire.Doc.Documents;
using System.Drawing;
using Spire.Doc.Fields;
namespace Spire.Doc
{
class Program
{
static void Main(string[] args)
{
//Create document
Document doc = new Document();
Section section = doc.AddSection();
//Declare a paragraph style
ParagraphStyle style1 = new ParagraphStyle(doc);
style1.Name = "Style1";
style1.CharacterFormat.Bold = true;
style1.CharacterFormat.TextColor = Color.Gray;
style1.CharacterFormat.FontSize = 18;
doc.Styles.Add(style1);
//Add paragraph and apply the declared style
Paragraph para1 = section.AddParagraph();
para1.Format.HorizontalAlignment = HorizontalAlignment.Center;
para1.AppendText("This is the first paragraph");
para1.ApplyStyle(style1.Name);
//Add paragraph and set its style
Paragraph para2 = section.AddParagraph();
para2.Format.HorizontalAlignment = HorizontalAlignment.Left;
TextRange range=para2.AppendText("This is the second paragraph");
range.CharacterFormat.Italic = true;
range.CharacterFormat.TextColor = Color.Red;
range.CharacterFormat.UnderlineStyle = UnderlineStyle.Dash;
range.CharacterFormat.SubSuperScript = SubSuperScript.BaseLine;
range.CharacterFormat.Border.BorderType = Spire.Doc.Documents.BorderStyle.Wave;
range.CharacterFormat.Border.Color = Color.Green;
//Save and Launch
doc.SaveToFile("TextStyle.docx", FileFormat.Docx2013);
System.Diagnostics.Process.Start("TextStyle.docx");
}
}
}