ParagraphStyle Class

Text style settings to be used if there is no matching TextStyle object in Styles collection either this object doesn't specify a needed setting.
Inheritance Hierarchy
SystemObject
  Aspose.NoteParagraphStyle

Namespace:  Aspose.Note
Assembly:  Aspose.Note (in Aspose.Note.dll) Version: 21.9
Syntax
public sealed class ParagraphStyle : IEquatable<ParagraphStyle>

The ParagraphStyle type exposes the following members.

Constructors
  NameDescription
Public methodParagraphStyle
Initializes a new instance of the ParagraphStyle class
Properties
  NameDescription
Public propertyStatic memberDefault
Gets the ParagraphStyle with default settings.
Public propertyCode exampleFontColor
Gets or sets the font color.
Public propertyCode exampleFontName
Gets or sets the font name.
Public propertyCode exampleFontSize
Gets or sets the font size.
Public propertyFontStyle
Gets the font style.
Public propertyHighlight
Gets or sets the highlight color.
Public propertyCode exampleIsBold
Gets or sets a value indicating whether the text style is bold.
Public propertyCode exampleIsItalic
Gets or sets a value indicating whether the text style is italic.
Public propertyIsStrikethrough
Gets or sets a value indicating whether the text style is strikethrough.
Public propertyIsSubscript
Gets or sets a value indicating whether the text style is subscript.
Public propertyIsSuperscript
Gets or sets a value indicating whether the text style is superscript.
Public propertyIsUnderline
Gets or sets a value indicating whether the text style is underline.
Methods
  NameDescription
Public methodEquals(Object)
Determines whether the specified object is equal to the current object.
(Overrides ObjectEquals(Object).)
Public methodEquals(ParagraphStyle)
Determines whether the specified object is equal to the current object.
Public methodGetHashCode
Serves as a hash function for the type.
(Overrides ObjectGetHashCode.)
Public methodGetType (Inherited from Object.)
Public methodToString (Inherited from Object.)
Examples
Let's format table for better perception. Make header row bold and italic, highlight every even row using LightGray color.
string dataDir = RunExamples.GetDataDir_Tables();

// Load the document into Aspose.Note.
Document document = new Document(dataDir + "ChangeTableStyleIn.one");

// Get a list of table nodes
IList<Table> nodes = document.GetChildNodes<Table>();

foreach (Table table in nodes)
{
    SetRowStyle(table.First(), Color.DarkGray, true, true);

    // Highlight first row after head.
    var flag = false;
    foreach (var row in table.Skip(1))
    {
        SetRowStyle(row, flag ? Color.LightGray : Color.Empty, false, false);

        flag = !flag;
    }
}

document.Save(Path.Combine(dataDir, "ChangeTableStyleOut.one"));
Examples
Manipulate by text format using paragraph style.
var document = new Document();
var page = new Page(document);
var outline = new Outline(document);
var outlineElem = new OutlineElement(document);

var text = new RichText(document)
            {
                Text = $"DefaultParagraphFontAndSize{Environment.NewLine}OnlyDefaultParagraphFont{Environment.NewLine}OnlyDefaultParagraphFontSize",
                ParagraphStyle = new ParagraphStyle()
                                    {
                                        FontName = "Courier New",
                                        FontSize = 20
                                    }
            };

// Font and font size are from text.ParagraphStyle
text.Styles.Add(new TextStyle()
                        {
                            RunIndex = 27
                        });

// Only font is from text.ParagraphStyle
text.Styles.Add(new TextStyle()
                        {
                            FontSize = 14,
                            RunIndex = 53
                        });

// Only font size is from text.ParagraphStyle
text.Styles.Add(new TextStyle()
                        {
                            FontName = "Verdana",
                            RunIndex = text.Text.Length
                        });

outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
document.AppendChildLast(page);

document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetDefaultParagraphStyle.one"));
Examples
Shows how to insert new list with chinese numbering.
string dataDir = RunExamples.GetDataDir_Text();

// Initialize OneNote document
Aspose.Note.Document doc = new Aspose.Note.Document();

// Initialize OneNote page
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);

// Apply text style settings
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };

// Numbers in the same outline are automatically incremented.
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);

// Save OneNote document
dataDir = dataDir + "InsertChineseNumberList_out.one"; 
doc.Save(dataDir);
Examples
Shows how to insert new bulleted lis.
string dataDir = RunExamples.GetDataDir_Text();

// Create an object of the Document class
Aspose.Note.Document doc = new Aspose.Note.Document();

// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);

// Initialize Outline class object
Outline outline = new Outline(doc);

// Initialize TextStyle class object and set formatting properties
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };

// Initialize OutlineElement class objects and apply bullets
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };

// Initialize RichText class object and apply text style
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);

// Add outline elements
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);

// Add Outline node
page.AppendChildLast(outline);
// Add Page node
doc.AppendChildLast(page);

// Save OneNote document
dataDir = dataDir + "ApplyBulletsOnText_out.one"; 
doc.Save(dataDir);
Examples
Shows how to insert new list with numbering.
string dataDir = RunExamples.GetDataDir_Text();

// Create an object of the Document class
Document doc = new Document();

// Initialize Page class object
Aspose.Note.Page page = new Aspose.Note.Page(doc);

// Initialize Outline class object
Outline outline = new Outline(doc);

// Initialize TextStyle class object and set formatting properties
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };

// Initialize OutlineElement class objects and apply numbering
// Numbers in the same outline are automatically incremented.
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);

// Add outline elements
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);

// Add Outline node
page.AppendChildLast(outline);

// Add Page node
doc.AppendChildLast(page);

// Save OneNote document
dataDir = dataDir + "ApplyNumberingOnText_out.one"; 
doc.Save(dataDir);
See Also