Class Style

Class Style

Namespace: Aspose.Note
Assembly: Aspose.Note.dll (25.6.0)

This class contains common properties of Aspose.Note.ParagraphStyle and Aspose.Note.TextStyle classes.

public class Style
{
    private string name;
    private Style parentStyle;
    public Style(string name)
    {
        this.name = name;
        this.parentStyle = null;
    }
    public string Name
    {
        get { return this.name; }
    }
    public Style ParentStyle
    {
        get { return this.parentStyle; }
    }
    public void AddChild(Style child)
    {
        if (child != null)
        {
            child.parentStyle = this;
        }
    }
}

Inheritance

object Style

Derived

ParagraphStyle , TextStyle

Inherited Members

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Constructors

Style()

Initializes a new instance of the Aspose.Note.Style class.

protected Style emptyStyle
   {
      get
      {
         return new Style();
      }
   }

Properties

FontColor

Gets or sets the font color.

public Color FontColor
   {
      get;
      private set;
   }

Property Value

Color

Examples

Shows how to change style for a text.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   var richText = document.GetChildNodes<RichText>().First();
   foreach (var run in richText.TextRuns)
   {
      run.Style.FontColor = Color.Yellow;
      run.Style.Highlight = Color.Blue;
      run.Style.FontSize = 20;
   }

Shows how to apply Dark theme style to a Document.

string dataDir = RunExamples.GetDataDir_Text();
   Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
   foreach (var page in doc)
   {
       page.BackgroundColor = Color.Black;
   }
   foreach (var node in doc.GetChildNodes<Aspose.Words.Document.Rtf.RichText>())
   {
       var c = node.ParagraphStyle.FontColor;
       if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
       {
           node.ParagraphStyle.FontColor = Color.White;
       }
   }
   doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));

Shows how to insert new list with chinese numbering.

string dataDir = RunExamples.GetDataDir_Text();
   Aspose.Note.Document doc = new Aspose.Note.Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle
   {
      FontColor = Color.Black,
      FontName = "Arial",
      FontSize = 10
   };
   OutlineElement outlineElem1 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
   };
   RichText text1 = new RichText(doc)
   {
      Text = "First",
      ParagraphStyle = defaultStyle
   };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
   };
   RichText text2 = new RichText(doc)
   {
      Text = "Second",
      ParagraphStyle = defaultStyle
   };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
   };
   RichText text3 = new RichText(doc)
   {
      Text = "Third",
      ParagraphStyle = defaultStyle
   };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "InsertChineseNumberList_out.one";
   doc.Save(dataDir);

Shows how to insert new bulleted lis.

string dataDir = RunExamples.GetDataDir_Text();
   Aspose.Note.Document doc = new Aspose.Note.Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle
      {
         FontColor = Color.Black,
         FontName = "Arial",
         FontSize = 10
      };
   OutlineElement outlineElem1 = new OutlineElement(doc)
   {
      NumberList = new NumberList("*", "Arial", 10)
   };
   RichText text1 = new RichText(doc)
   {
      Text = "First",
      ParagraphStyle = defaultStyle
   };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc)
   {
      NumberList = new NumberList("*", "Arial", 10)
   };
   RichText text2 = new RichText(doc)
   {
      Text = "Second",
      ParagraphStyle = defaultStyle
   };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc)
   {
      NumberList = new NumberList("*", "Arial", 10)
   };
   RichText text3 = new RichText(doc)
   {
      Text = "Third",
      ParagraphStyle = defaultStyle
   };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "ApplyBulletsOnText_out.one";
   doc.Save(dataDir);

Shows how to insert new list with numbering.

string dataDir = RunExamples.GetDataDir_Text();
   Document doc = new Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
   OutlineElement outlineElem1 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
   };
   RichText text1 = new RichText(doc)
   {
      Text = "First",
      ParagraphStyle = defaultStyle
   };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
   };
   RichText text2 = new RichText(doc)
   {
      Text = "Second",
      ParagraphStyle = defaultStyle
   };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
   };
   RichText text3 = new RichText(doc)
   {
      Text = "Third",
      ParagraphStyle = defaultStyle
   };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "ApplyNumberingOnText_out.one";
   doc.Save(dataDir);

Shows how to bind a hyperlink to a text.

string dataDir = RunExamples.GetDataDir_Tasks();
   Document doc = new Document();
   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
   Outline outline = new Outline()
   {
       MaxWidth = 200,
       MaxHeight = 200,
       VerticalOffset = 100,
       HorizontalOffset = 100
   };
   TextStyle textStyleRed = new TextStyle
   {
       FontColor = Color.Red,
       FontName = "Arial",
       FontSize = 10,
   };
   TextStyle textStyleHyperlink = new TextStyle
   {
       IsHyperlink = true,
       HyperlinkAddress = "www.google.com"
   };
   RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
       .Append("This is ", textStyleRed)
       .Append("hyperlink", textStyleHyperlink)
       .Append(". This text is not a hyperlink.", TextStyle.Default);
   OutlineElement outlineElem = new OutlineElement();
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   Title title = new Title() { TitleText = titleText };
   Note.Page page = new Note.Page() { Title = title };
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "AddHyperlink_out.one";
   doc.Save(dataDir);

Shows how to compose a table having text with various styles.

string dataDir = RunExamples.GetDataDir_Text();
   var headerText = new RichText()
   {
      ParagraphStyle = new ParagraphStyle()
      {
         FontSize = 18,
         IsBold = true
      },
      Alignment = HorizontalAlignment.Center
   }
   .Append("Super contest for suppliers.");
   var page = new Page();
   var outline = page.AppendChildLast(new Outline() { HorizontalOffset = 50 });
   outline.AppendChildLast(new OutlineElement()).AppendChildLast(headerText);
   var bodyTextHeader = outline.AppendChildLast(new OutlineElement()).AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default });
   bodyTextHeader.Append("This is the final ranking of proposals got from our suppliers.");
   var ranking = outline.AppendChildLast(new OutlineElement()).AppendChildLast(new Table());
   var headerRow = ranking.AppendChildFirst(new TableRow());
   var headerStyle = ParagraphStyle.Default;
   headerStyle.IsBold = true;
   var backGroundColor = Color.LightGray;
   foreach (var header in new[] { "Supplier", "Contacts", "Score A", "Score B", "Score C", "Final score", "Attached materials", "Comments" })
   {
      ranking.Columns.Add(new TableColumn());
      headerRow.AppendChildLast(new TableCell() { BackgroundColor = backGroundColor })
             .AppendChildLast(new OutlineElement())
             .AppendChildLast(new RichText() { ParagraphStyle = headerStyle })
             .Append(header);
   }
   for (int i = 0; i < 5; i++)
   {
      backGroundColor = backGroundColor.IsEmpty ? Color.LightGray : Color.Empty;
      var row = ranking.AppendChildLast(new TableRow());
      for (int j = 0; j < ranking.Columns.Count(); j++)
      {
         row.AppendChildLast(new TableCell() { BackgroundColor = backGroundColor })
            .AppendChildLast(new OutlineElement())
            .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default });
      }
   }
   foreach (var row in ranking.Skip(1))
   {
      var contactsCell = row.ElementAt(1);
      contactsCell.AppendChildLast(new OutlineElement())
                  .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default })
                  .Append("Web: ").Append("link", new TextStyle() { HyperlinkAddress = "www.link.com", IsHyperlink = true });
      contactsCell.AppendChildLast(new OutlineElement())
                  .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default })
                  .Append("E-mail: ").Append("mail", new TextStyle() { HyperlinkAddress = "mailto:hi@link.com", IsHyperlink = true });
   }
   var d = new Document();
   d.AppendChildLast(page);
   d.Save(Path.Combine(dataDir, "ComposeTable_out.one"));

FontName

Gets or sets the font name.

public string FontName
{
    get;
    private set;
}

Property Value

string

Examples

Manipulate by text format using paragraph style.

var document = new Document();
   var page = new Page();
   var outline = new Outline();
   var outlineElem = new OutlineElement();
   var text = new RichText()
      .Append($"DefaultParagraphFontAndSize{Environment.NewLine}")
      .Append($"OnlyDefaultParagraphFont{Environment.NewLine}", new TextStyle() { FontSize = 14 })
      .Append("OnlyDefaultParagraphFontSize", new TextStyle() { FontName = "Verdana" });
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   page.AppendChildLast(outline);
   document.AppendChildLast(page);
   document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetDefaultParagraphStyle.one"));

Shows how to insert new list with chinese numbering.

string dataDir = RunExamples.GetDataDir_Text();
   Aspose.Note.Document doc = new Aspose.Note.Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle() { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
   OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
   RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
   RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
   RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "InsertChineseNumberList_out.one";
   doc.Save(dataDir);

Shows how to insert new bulleted lis.

string dataDir = RunExamples.GetDataDir_Text();
   Aspose.Note.Document doc = new Aspose.Note.Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
   OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
   RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
   RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
   RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "ApplyBulletsOnText_out.one";
   doc.Save(dataDir);

Shows how to insert new list with numbering.

string dataDir = RunExamples.GetDataDir_Text();
   Document doc = new Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle
      {
         FontColor = Color.Black,
         FontName = "Arial",
         FontSize = 10
      };
   OutlineElement outlineElem1 = new OutlineElement(doc)
      {
         NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
      };
   RichText text1 = new RichText(doc)
      {
         Text = "First",
         ParagraphStyle = defaultStyle
      };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc)
      {
         NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
      };
   RichText text2 = new RichText(doc)
      {
         Text = "Second",
         ParagraphStyle = defaultStyle
      };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc)
      {
         NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
      };
   RichText text3 = new RichText(doc)
      {
         Text = "Third",
         ParagraphStyle = defaultStyle
      };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "ApplyNumberingOnText_out.one";
   doc.Save(dataDir);

Shows how to bind a hyperlink to a text.

string dataDir = RunExamples.GetDataDir_Tasks();
   Document doc = new Document();
   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
   Outline outline = new Outline()
   {
       MaxWidth = 200,
       MaxHeight = 200,
       VerticalOffset = 100,
       HorizontalOffset = 100
   };
   TextStyle textStyleRed = new TextStyle
   {
       FontColor = Color.Red,
       FontName = "Arial",
       FontSize = 10,
   };
   TextStyle textStyleHyperlink = new TextStyle
   {
       IsHyperlink = true,
       HyperlinkAddress = "www.google.com"
   };
   RichText text = new RichText()
       .Append("This is ", textStyleRed)
       .Append("hyperlink", textStyleHyperlink)
       .Append(". This text is not a hyperlink.", TextStyle.Default);
   OutlineElement outlineElem = new OutlineElement();
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   Title title = new Title() { TitleText = titleText };
   Page page = new Note.Page() { Title = title };
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "AddHyperlink_out.one";
   doc.Save(dataDir);

FontSize

Gets or sets the font size.

public int? fontSize { get; set; }

Property Value

int ?

Examples

Shows how to change style for a text.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   var richText = document.GetChildNodes<RichText>().First();
   foreach (var run in richText.TextRuns)
   {
      run.Style.FontColor = Color.Yellow;
      run.Style.Highlight = Color.Blue;
      run.Style.FontSize = 20;
   }

Let’s emphasize page’s titles among other headers by increasing font’s size.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   foreach (var title in document.Select(e => e.Title.TitleText))
   {
       title.ParagraphStyle.FontSize = 24;
       title.ParagraphStyle.IsBold = true;
       foreach (var run in title.TextRuns)
       {
           run.Style.FontSize = 24;
           run.Style.IsBold = true;
       }
   }
   document.Save(Path.Combine(dataDir, "ChangePageTitleStyle.pdf"));

Let’s emphasize latest text’s changes by highlighting.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   var richTextNodes = document.GetChildNodes<RichText>()
       .Where(e => e.LastModifiedTime >= DateTime.Today.AddDays(-7));
   foreach (var node in richTextNodes)
   {
       node.ParagraphStyle.Highlight = Color.DarkGreen;
       foreach (var run in node.TextRuns)
       {
           run.Style.Highlight = Color.DarkSeaGreen;
       }
   }
   document.Save(Path.Combine(dataDir, "HighlightAllRecentChanges.pdf"));

Manipulate by text format using paragraph style.

var document = new Document();
      var page = new Page();
      var outline = new Outline();
      var outlineElem = new OutlineElement();
      var text = new RichText()
         {
            ParagraphStyle = new ParagraphStyle()
            {
               FontName = "Courier New",
               FontSize = 20
            }
         }
         .Append($"DefaultParagraphFontAndSize{Environment.NewLine}")
         .Append($"OnlyDefaultParagraphFont{Environment.NewLine}", new TextStyle() { FontSize = 14 })
         .Append("OnlyDefaultParagraphFontSize", new TextStyle() { FontName = "Verdana" });
      outlineElem.AppendChildLast(text);
      outline.AppendChildLast(outlineElem);
      page.AppendChildLast(outline);
      document.AppendChildLast(page);
      document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetDefaultParagraphStyle.one"));

Shows how to insert new list with chinese numbering.

string dataDir = RunExamples.GetDataDir_Text();
   Aspose.Note.Document doc = new Aspose.Note.Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle
   {
      FontColor = Color.Black,
      FontName = "Arial",
      FontSize = 10
   };
   OutlineElement outlineElem1 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
   };
   RichText text1 = new RichText(doc)
   {
      Text = "First",
      ParagraphStyle = defaultStyle
   };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
   };
   RichText text2 = new RichText(doc)
   {
      Text = "Second",
      ParagraphStyle = defaultStyle
   };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc)
   {
      NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
   };
   RichText text3 = new RichText(doc)
   {
      Text = "Third",
      ParagraphStyle = defaultStyle
   };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir = dataDir + "InsertChineseNumberList_out.one";
   doc.Save(dataDir);

Shows how to insert new bulleted lis.

string dataDir = RunExamples.GetDataDir_Text();
   Aspose.Note.Document doc = new Aspose.Note.Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle
   {
       FontColor = Color.Black,
       FontName = "Arial",
       FontSize = 10
   };
   OutlineElement outlineElem1 = new OutlineElement(doc)
   {
       NumberList = new NumberList("*", "Arial", 10)
   };
   RichText text1 = new RichText(doc)
   {
       Text = "First",
       ParagraphStyle = defaultStyle
   };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc)
   {
       NumberList = new NumberList("*", "Arial", 10)
   };
   RichText text2 = new RichText(doc)
   {
       Text = "Second",
       ParagraphStyle = defaultStyle
   };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc)
   {
       NumberList = new NumberList("*", "Arial", 10)
   };
   RichText text3 = new RichText(doc)
   {
       Text = "Third",
       ParagraphStyle = defaultStyle
   };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "ApplyBulletsOnText_out.one";
   doc.Save(dataDir);

Shows how to insert new list with numbering.

string dataDir = RunExamples.GetDataDir_Text();
   Document doc = new Document();
   Aspose.Note.Page page = new Aspose.Note.Page(doc);
   Outline outline = new Outline(doc);
   ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
   OutlineElement outlineElem1 = new OutlineElement(doc)
   {
       NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
   };
   RichText text1 = new RichText(doc)
   {
       Text = "First",
       ParagraphStyle = defaultStyle
   };
   outlineElem1.AppendChildLast(text1);
   OutlineElement outlineElem2 = new OutlineElement(doc)
   {
       NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
   };
   RichText text2 = new RichText(doc)
   {
       Text = "Second",
       ParagraphStyle = defaultStyle
   };
   outlineElem2.AppendChildLast(text2);
   OutlineElement outlineElem3 = new OutlineElement(doc)
   {
       NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
   };
   RichText text3 = new RichText(doc)
   {
       Text = "Third",
       ParagraphStyle = defaultStyle
   };
   outlineElem3.AppendChildLast(text3);
   outline.AppendChildLast(outlineElem1);
   outline.AppendChildLast(outlineElem2);
   outline.AppendChildLast(outlineElem3);
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "ApplyNumberingOnText_out.one";
   doc.Save(dataDir);

Shows how to bind a hyperlink to a text.

string dataDir = RunExamples.GetDataDir_Tasks();
   Document doc = new Document();
   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");
   Outline outline = new Outline()
   {
       MaxWidth = 200,
       MaxHeight = 200,
       VerticalOffset = 100,
       HorizontalOffset = 100
   };
   TextStyle textStyleRed = new TextStyle
   {
       FontColor = Color.Red,
       FontName = "Arial",
       FontSize = 10,
   };
   TextStyle textStyleHyperlink = new TextStyle
   {
       IsHyperlink = true,
       HyperlinkAddress = "www.google.com"
   };
   RichText text = new RichText()
       .Append("This is ", textStyleRed)
       .Append("hyperlink", textStyleHyperlink)
       .Append(". This text is not a hyperlink.", TextStyle.Default);
   OutlineElement outlineElem = new OutlineElement();
   outlineElem.AppendChildLast(text);
   outline.AppendChildLast(outlineElem);
   Title title = new Title() { TitleText = titleText };
   Note.Page page = new Note.Page() { Title = title };
   page.AppendChildLast(outline);
   doc.AppendChildLast(page);
   dataDir += "AddHyperlink_out.one";
   doc.Save(dataDir);

Shows how to compose a table having text with various styles.

string dataDir = RunExamples.GetDataDir_Text();
   var headerText = new RichText()
   {
      ParagraphStyle = new ParagraphStyle()
      {
         FontSize = 18,
         IsBold = true
      },
      Alignment = HorizontalAlignment.Center
   }
   .Append("Super contest for suppliers.")
   var page = new Page();
   var outline = page.AppendChildLast(new Outline() { HorizontalOffset = 50 });
   outline.AppendChildLast(new OutlineElement()).AppendChildLast(headerText);
   var bodyTextHeader = outline.AppendChildLast(new OutlineElement()).AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default });
   bodyTextHeader.Append("This is the final ranking of proposals got from our suppliers.");
   var ranking = outline.AppendChildLast(new OutlineElement()).AppendChildLast(new Table());
   var headerRow = ranking.AppendChildFirst(new TableRow());
   var headerStyle = ParagraphStyle.Default;
   headerStyle.IsBold = true;
   var backGroundColor = Color.LightGray;
   foreach (var header in new[] { "Supplier", "Contacts", "Score A", "Score B", "Score C", "Final score", "Attached materials", "Comments" })
   {
      ranking.Columns.Add(new TableColumn());
      headerRow.AppendChildLast(new TableCell() { BackgroundColor = backGroundColor })
             .AppendChildLast(new OutlineElement())
             .AppendChildLast(new RichText() { ParagraphStyle = headerStyle })
             .Append(header);
   }
   for (int i = 0; i < 5; i++)
   {
      backGroundColor = backGroundColor.IsEmpty ? Color.LightGray : Color.Empty;
      var row = ranking.AppendChildLast(new TableRow());
      for (int j = 0; j < ranking.Columns.Count(); j++)
      {
         row.AppendChildLast(new TableCell() { BackgroundColor = backGroundColor })
            .AppendChildLast(new OutlineElement())
            .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default });
      }
   }
   foreach (var row in ranking.Skip(1))
   {
      var contactsCell = row.ElementAt(1);
      contactsCell.AppendChildLast(new OutlineElement())
                  .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default })
                    .Append("Web: ").Append("link", new TextStyle() { HyperlinkAddress = "www.link.com", IsHyperlink = true });
      contactsCell.AppendChildLast(new OutlineElement())
                  .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default })
                    .Append("E-mail: ").Append("mail", new TextStyle() { HyperlinkAddress = "mailto:hi@link.com", IsHyperlink = true });
   }
   var d = new Document();
   d.AppendChildLast(page);
   d.Save(Path.Combine(dataDir, "ComposeTable_out.one"));

FontStyle

Gets the font style.

public FontStyle FontStyle
   {
      get
      {
         return _fontStyle;
      }
   }
Here's the reformatted code with proper indentation, spacing, and general readability improvements.

Property Value

FontStyle

Highlight

Gets or sets the highlight color.

public Color Highlight
   {
      get;
      set;
   }

Property Value

Color

Examples

Shows how to change style for a text.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   RichText richText = document.GetChildNodes<RichText>().First();
   foreach (var run in richText.TextRuns)
   {
       run.Style.FontColor = Color.Yellow;
       run.Style.Highlight = Color.Blue;
       run.Style.FontSize = 20;
   }

Shows how to compose a table having text with various styles.

string dataDir = RunExamples.GetDataDir_Text();
   var headerText = new RichText()
   {
      ParagraphStyle = new ParagraphStyle()
      {
         FontSize = 18,
         IsBold = true
      },
      Alignment = HorizontalAlignment.Center
   }
   .Append("Super contest for suppliers.")
   var page = new Page();
   var outline = page.AppendChildLast(new Outline() { HorizontalOffset = 50 });
   outline.AppendChildLast(new OutlineElement()).AppendChildLast(headerText);
   var bodyTextHeader = outline.AppendChildLast(new OutlineElement()).AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default });
   bodyTextHeader.Append("This is the final ranking of proposals got from our suppliers.");
   var ranking = outline.AppendChildLast(new OutlineElement()).AppendChildLast(new Table());
   var headerRow = ranking.AppendChildFirst(new TableRow());
   var headerStyle = ParagraphStyle.Default;
   headerStyle.IsBold = true;
   var backGroundColor = Color.LightGray;
   foreach (var header in new[] { "Supplier", "Contacts", "Score A", "Score B", "Score C", "Final score", "Attached materials", "Comments" })
   {
      ranking.Columns.Add(new TableColumn());
      headerRow.AppendChildLast(new TableCell() { BackgroundColor = backGroundColor })
             .AppendChildLast(new OutlineElement())
             .AppendChildLast(new RichText() { ParagraphStyle = headerStyle })
             .Append(header);
   }
   for (int i = 0; i < 5; i++)
   {
      backGroundColor = backGroundColor.IsEmpty ? Color.LightGray : Color.Empty;
      var row = ranking.AppendChildLast(new TableRow());
      for (int j = 0; j < ranking.Columns.Count(); j++)
      {
         row.AppendChildLast(new TableCell() { BackgroundColor = backGroundColor })
            .AppendChildLast(new OutlineElement())
            .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default });
      }
   }
   foreach (var row in ranking.Skip(1))
   {
      var contactsCell = row.ElementAt(1);
      contactsCell.AppendChildLast(new OutlineElement())
                  .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default })
                    .Append("Web: ").Append("link", new TextStyle() { HyperlinkAddress = "www.link.com", IsHyperlink = true });
      contactsCell.AppendChildLast(new OutlineElement())
                  .AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default })
                    .Append("E-mail: ").Append("mail", new TextStyle() { HyperlinkAddress = "mailto:hi@link.com", IsHyperlink = true });
   }
   var d = new Document();
   d.AppendChildLast(page);
   d.Save(Path.Combine(dataDir, "ComposeTable_out.one"));

IsBold

Gets or sets a value indicating whether the text style is bold.

public bool IsBold
   {
      get;
      set;
   }

Property Value

bool

Examples

Let’s emphasize page’s titles among other headers by increasing font’s size.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   foreach (var title in document.Select(e => e.Title.TitleText))
   {
       title.ParagraphStyle.FontSize = 24;
       title.ParagraphStyle.IsBold = true;
       foreach (var run in title.TextRuns)
       {
           run.Style.FontSize = 24;
           run.Style.IsBold = true;
       }
   }
   document.Save(Path.Combine(dataDir, "ChangePageTitleStyle.pdf"));

Let’s emphasize latest text’s changes by highlighting.

string dataDir = RunExamples.GetDataDir_Text();
   Document document = new Document(dataDir + "Aspose.one");
   var richTextNodes = document.GetChildNodes<RichText>()
      .Where(e => e.LastModifiedTime >= DateTime.Today.Subtract(TimeSpan.FromDays(7)));
   foreach (var node in richTextNodes)
   {
       node.ParagraphStyle.Highlight = Color.DarkGreen;
       foreach (var run in node.TextRuns)
       {
           run.Style.Highlight = Color.DarkSeaGreen;
       }
   }
   document.Save(Path.Combine(dataDir, "HighlightAllRecentChanges.pdf"));

IsItalic

Gets or sets a value indicating whether the text style is italic.

public bool IsItalic
   {
      get;
      set;
   }

Property Value

bool

IsStrikethrough

Gets or sets a value indicating whether the text style is strikethrough.

public bool IsStrikethrough
{
    get;
    private set;
}

Property Value

bool

IsSubscript

Gets or sets a value indicating whether the text style is subscript.

public bool IsSubscript
    {
        get;
        private set;
    }

Property Value

bool

IsSuperscript

Gets or sets a value indicating whether the text style is superscript.

public bool IsSuperscript
    {
        get;
        set;
    }

Property Value

bool

IsUnderline

Gets or sets a value indicating whether the text style is underline.

public bool IsUnderline
    {
        get;
        private set;
    }

Property Value

bool

Methods

GetHashCode()

Serves as a hash function for the type.

public override int GetHashCode()
    {
    }

Returns

int

The System.Int32.

 English