Exemplo n.º 1
0
        public static void Run()
        {
            // ExStart:InsertImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Images();

            // Load document from the stream.
            Document doc = new Document(dataDir + "Aspose.one");

            // Get the first page of the document.
            Aspose.Note.Page page = doc.FirstChild;

            // Load an image from the file.
            Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg");
            // Change the image's size according to your needs (optional).
            image.Width  = 100;
            image.Height = 100;
            // Set the image's location in the page (optional).
            image.VerticalOffset   = 400;
            image.HorizontalOffset = 100;
            // Set image alignment
            image.Alignment = HorizontalAlignment.Right;
            // Add the image to the page.
            page.AppendChild(image);
            // ExEnd:InsertImage
            Console.WriteLine("\nImage inserted successfully to OneNote document.");
        }
        public static void Run()
        {
            // ExStart:AttachFileAndSetIcon
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Attachments();

            // 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 OutlineElement class object
            OutlineElement outlineElem = new OutlineElement(doc);
            // Initialize AttachedFile class object and also pass its icon path
            AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", File.OpenRead(dataDir + "icon.jpg"), ImageFormat.Jpeg);

            // Add attached file
            outlineElem.AppendChild(attachedFile);
            // Add outline element node
            outline.AppendChild(outlineElem);
            // Add outline node
            page.AppendChild(outline);
            // Add page node
            doc.AppendChild(page);

            dataDir = dataDir + "AttachFileAndSetIcon_out.one";
            doc.Save(dataDir);
            // ExEnd:AttachFileAndSetIcon

            Console.WriteLine("\nFile attached and it's icon setup successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:AttachFileByPath
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Attachments();

            // 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 OutlineElement class object
            OutlineElement outlineElem = new OutlineElement(doc);
            // Initialize AttachedFile class object
            AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt");

            // Add attached file
            outlineElem.AppendChild(attachedFile);
            // Add outline element node
            outline.AppendChild(outlineElem);
            // Add outline node
            page.AppendChild(outline);
            // Add page node
            doc.AppendChild(page);
            dataDir = dataDir + "AttachFileByPath_out.one";
            doc.Save(dataDir);
            // ExEnd:AttachFileByPath

            Console.WriteLine("\nFile by path attached successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:CreateTableWithLockedColumns
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tables();

            // 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 TableRow class object
            TableRow row1 = new TableRow(doc);
            // Initialize TableCell class object and set text content
            TableCell cell11 = new TableCell(doc);

            cell11.AppendChild(InsertTable.GetOutlineElementWithText(doc, "Small text"));
            row1.AppendChild(cell11);

            // Initialize TableRow class object
            TableRow row2 = new TableRow(doc);
            // Initialize TableCell class object and set text content
            TableCell cell21 = new TableCell(doc);

            cell21.AppendChild(InsertTable.GetOutlineElementWithText(doc, "Long   text    with    several   words and    spaces."));
            row2.AppendChild(cell21);

            // Initialize Table class object
            Table table = new Table(doc)
            {
                IsBordersVisible = true,
                Columns          = { new TableColumn {
                                         Width = 70, LockedWidth = true
                                     } }
            };

            // Add rows
            table.AppendChild(row1);
            table.AppendChild(row2);

            Outline        outline     = new Outline(doc);
            OutlineElement outlineElem = new OutlineElement(doc);

            // Add table node
            outlineElem.AppendChild(table);
            // Add outline element node
            outline.AppendChild(outlineElem);
            // Add outline node
            page.AppendChild(outline);
            // Add page node
            doc.AppendChild(page);
            dataDir = dataDir + "CreateTableWithLockedColumns_out_.one";
            doc.Save(dataDir);
            // ExEnd:CreateTableWithLockedColumns

            Console.WriteLine("\nTable with locked columns created successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:AddTableNodeWithTag
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tags();

            // 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 TableRow class object
            TableRow row = new TableRow(doc);
            // Initialize TableCell class object
            TableCell cell = new TableCell(doc);

            // Insert cell content
            cell.AppendChild(InsertTable.GetOutlineElementWithText(doc, "Single cell."));
            // Add cell to row node
            row.AppendChild(cell);
            // Initialize table node
            Table table = new Table(doc)
            {
                IsBordersVisible = true,
                Columns          = { new TableColumn {
                                         Width = 70
                                     } }
            };

            // Insert row node in table
            table.AppendChild(row);
            // Add tag to this table node
            table.Tags.Add(new NoteTag
            {
                Icon = TagIcon.QuestionMark
            });

            Outline        outline     = new Outline(doc);
            OutlineElement outlineElem = new OutlineElement(doc);

            // Add table node
            outlineElem.AppendChild(table);
            // Add outline elements
            outline.AppendChild(outlineElem);
            page.AppendChild(outline);
            doc.AppendChild(page);

            dataDir = dataDir + "AddTableNodeWithTag_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:AddTableNodeWithTag
            Console.WriteLine("\nTable node with tag added successfully.\nFile saved at " + dataDir);
        }
Exemplo n.º 6
0
        public static void Run()
        {
            // ExStart:AddTextNodeWithTag
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tags();

            // 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 OutlineElement class object
            OutlineElement outlineElem = new OutlineElement(doc);
            TextStyle      textStyle   = new TextStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };
            RichText text = new RichText(doc)
            {
                Text = "OneNote text.", DefaultStyle = textStyle
            };

            text.Tags.Add(new NoteTag
            {
                Icon = TagIcon.YellowStar,
            });

            // Add text node
            outlineElem.AppendChild(text);
            // Add outline element node
            outline.AppendChild(outlineElem);
            // Add outline node
            page.AppendChild(outline);
            // Add page node
            doc.AppendChild(page);

            dataDir = dataDir + "AddTextNodeWithTag_out_.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:AddTextNodeWithTag
            Console.WriteLine("\nText node with tag added successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:CreateDocWithSimpleRichText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

            // 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 OutlineElement class object
            OutlineElement outlineElem = new OutlineElement(doc);

            // Initialize TextStyle class object and set formatting properties
            TextStyle textStyle = new TextStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };
            // Initialize RichText class object and apply text style
            RichText text = new RichText(doc)
            {
                Text = "Hello OneNote text!", DefaultStyle = textStyle
            };

            // Add RichText node
            outlineElem.AppendChild(text);
            // Add OutlineElement node
            outline.AppendChild(outlineElem);
            // Add Outline node
            page.AppendChild(outline);
            // Add Page node
            doc.AppendChild(page);

            dataDir = dataDir + "CreateDocWithSimpleRichText_out_.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:CreateDocWithSimpleRichText

            Console.WriteLine("\nOneNote document created successfully with simple rich text.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:BuildDocAndInsertImage
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Images();

            // 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 and set offset properties
            Outline outline = new Outline(doc)
            {
                VerticalOffset = 0, HorizontalOffset = 0
            };
            // Initialize OutlineElement class object
            OutlineElement outlineElem = new OutlineElement(doc);

            // Load an image by the file path.
            Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "image.jpg");
            // Set image alignment
            image.Alignment = HorizontalAlignment.Right;
            // Add image
            outlineElem.AppendChild(image);
            // Add outline elements
            outline.AppendChild(outlineElem);
            // Add Outline node
            page.AppendChild(outline);
            // Add Page node
            doc.AppendChild(page);

            dataDir = dataDir + "BuildDocAndInsertImage_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:BuildDocAndInsertImage
            Console.WriteLine("\nDocument created and image inserted successfully.\nFile saved at " + dataDir);
        }
Exemplo n.º 9
0
        public static void Run()
        {
            // ExStart:AddImageNodeWithTag
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tags();

            // 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 OutlineElement class object
            OutlineElement outlineElem = new OutlineElement(doc);

            // Load an image
            Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "icon.jpg");
            // Insert image in the document node
            outlineElem.AppendChild(image);
            image.Tags.Add(new NoteTag
            {
                Icon = TagIcon.YellowStar,
            });
            // Add outline element node
            outline.AppendChild(outlineElem);
            // Add outline node
            page.AppendChild(outline);
            // Add page node
            doc.AppendChild(page);

            dataDir = dataDir + "AddImageNodeWithTag_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:AddImageNodeWithTag
            Console.WriteLine("\nImage node with tag added successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:BuildDocAndInsertImageUsingImageStream
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Images();

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

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

            Outline outline1 = new Outline(doc)
            {
                VerticalOffset = 600, HorizontalOffset = 0
            };
            OutlineElement outlineElem1 = new OutlineElement(doc);
            FileStream     fs           = File.OpenRead(dataDir + "image.jpg");

            // Load the second image using the image name, extension and stream.
            Aspose.Note.Image image1 = new Aspose.Note.Image(doc, "Penguins", "jpg", fs);
            // Set image alignment
            image1.Alignment = HorizontalAlignment.Right;

            outlineElem1.AppendChild(image1);
            outline1.AppendChild(outlineElem1);
            page.AppendChild(outline1);

            doc.AppendChild(page);

            dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:BuildDocAndInsertImageUsingImageStream
            Console.WriteLine("\nDocument created and image using image stream inserted successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:AddHyperlink
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tasks();

            // 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 Title class object
            Title title = new Title(doc);

            TextStyle defaultTextStyle = new TextStyle
            {
                FontName  = "Arial",
                FontSize  = 10,
                FontColor = SystemColors.WindowText
            };
            RichText titleText = new RichText(doc)
            {
                Text         = "Title!",
                DefaultStyle = defaultTextStyle
            };
            Outline outline = new Outline(doc)
            {
                MaxWidth         = 200,
                MaxHeight        = 200,
                VerticalOffset   = 100,
                HorizontalOffset = 100
            };
            OutlineElement outlineElem  = new OutlineElement(doc);
            TextStyle      textStyleRed = new TextStyle
            {
                FontColor = Color.Red,
                FontName  = "Arial",
                FontSize  = 10,
                RunIndex  = 8//this style will be applied to 0-7 characters.
            };
            TextStyle textStyleHyperlink = new TextStyle
            {
                RunIndex         = 17,//this style will be applied to 8-16 characters.
                IsHyperlink      = true,
                HyperlinkAddress = "www.google.com"
            };
            RichText text = new RichText(doc)
            {
                Text         = "This is hyperlink. This text is not a hyperlink.",
                DefaultStyle = defaultTextStyle,
                Styles       = { textStyleRed, textStyleHyperlink }
            };

            title.TitleText = titleText;
            page.Title      = title;
            outlineElem.AppendChild(text);
            // Add outline elements
            outline.AppendChild(outlineElem);
            // Add Outline node
            page.AppendChild(outline);
            // Add Page node
            doc.AppendChild(page);

            dataDir = dataDir + "AddHyperlink_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:AddHyperlink
            Console.WriteLine("\nHyperlink added successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:InsertTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tables();

            // 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 TableRow class object
            TableRow row1 = new TableRow(doc);
            // Initialize TableCell class objects
            TableCell cell11 = new TableCell(doc);
            TableCell cell12 = new TableCell(doc);
            TableCell cell13 = new TableCell(doc);

            // Append outline elements in the table cell
            cell11.AppendChild(GetOutlineElementWithText(doc, "cell_1.1"));
            cell12.AppendChild(GetOutlineElementWithText(doc, "cell_1.2"));
            cell13.AppendChild(GetOutlineElementWithText(doc, "cell_1.3"));
            // Table cells to rows
            row1.AppendChild(cell11);
            row1.AppendChild(cell12);
            row1.AppendChild(cell13);

            // Initialize TableRow class object
            TableRow row2 = new TableRow(doc);
            // initialize TableCell class objects
            TableCell cell21 = new TableCell(doc);
            TableCell cell22 = new TableCell(doc);
            TableCell cell23 = new TableCell(doc);

            // Append outline elements in the table cell
            cell21.AppendChild(GetOutlineElementWithText(doc, "cell_2.1"));
            cell22.AppendChild(GetOutlineElementWithText(doc, "cell_2.2"));
            cell23.AppendChild(GetOutlineElementWithText(doc, "cell_2.3"));

            // Append table cells to rows
            row2.AppendChild(cell21);
            row2.AppendChild(cell22);
            row2.AppendChild(cell23);

            // Initialize Table class object and set column widths
            Table table = new Table(doc)
            {
                IsBordersVisible = true,
                Columns          = { new TableColumn {
                                         Width = 200
                                     }, new TableColumn       {
                                         Width = 200
                                     }, new TableColumn       {
                                         Width = 200
                                     } }
            };

            // Append table rows to table
            table.AppendChild(row1);
            table.AppendChild(row2);

            // Initialize Outline object
            Outline outline = new Outline(doc);
            // Initialize OutlineElement object
            OutlineElement outlineElem = new OutlineElement(doc);

            // Add table to outline element node
            outlineElem.AppendChild(table);
            // Add outline element to outline
            outline.AppendChild(outlineElem);
            // Add outline to page node
            page.AppendChild(outline);
            // Add page to document node
            doc.AppendChild(page);
            dataDir = dataDir + "InsertTable_out.one";
            doc.Save(dataDir);
            // ExEnd:InsertTable

            Console.WriteLine("\nTable inserted successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:CreateDocWithRootAndSubPages
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Pages();

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

            // Initialize Page class object and set its level
            Aspose.Note.Page page1 = new Aspose.Note.Page(doc)
            {
                Level = 1
            };
            // Initialize Page class object and set its level
            Aspose.Note.Page page2 = new Aspose.Note.Page(doc)
            {
                Level = 2
            };
            // Initialize Page class object and set its level
            Aspose.Note.Page page3 = new Aspose.Note.Page(doc)
            {
                Level = 1
            };

            /*---------- Adding nodes to first Page ----------*/
            Outline        outline     = new Outline(doc);
            OutlineElement outlineElem = new OutlineElement(doc);
            TextStyle      textStyle   = new TextStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };
            RichText text = new RichText(doc)
            {
                Text = "First page.", DefaultStyle = textStyle
            };

            outlineElem.AppendChild(text);
            outline.AppendChild(outlineElem);
            page1.AppendChild(outline);

            /*---------- Adding nodes to second Page ----------*/
            var outline2     = new Outline(doc);
            var outlineElem2 = new OutlineElement(doc);
            var textStyle2   = new TextStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };
            var text2 = new RichText(doc)
            {
                Text = "Second page.", DefaultStyle = textStyle2
            };

            outlineElem2.AppendChild(text2);
            outline2.AppendChild(outlineElem2);
            page2.AppendChild(outline2);

            /*---------- Adding nodes to third Page ----------*/
            var outline3     = new Outline(doc);
            var outlineElem3 = new OutlineElement(doc);
            var textStyle3   = new TextStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };
            var text3 = new RichText(doc)
            {
                Text = "Third page.", DefaultStyle = textStyle3
            };

            outlineElem3.AppendChild(text3);
            outline3.AppendChild(outlineElem3);
            page3.AppendChild(outline3);

            /*---------- Add pages to the OneNote Document ----------*/
            doc.AppendChild(page1);
            doc.AppendChild(page2);
            doc.AppendChild(page3);

            dataDir = dataDir + "CreateDocWithRootAndSubPages_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:CreateDocWithRootAndSubPages
            Console.WriteLine("\nOneNote document created successfully with root and sub level pages.\nFile saved at " + dataDir);
        }
Exemplo n.º 14
0
        public static void Run()
        {
            // ExStart:ApplyNumberingOnText
            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
            TextStyle defaultStyle = new TextStyle {
                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", DefaultStyle = defaultStyle
            };

            outlineElem1.AppendChild(text1);

            OutlineElement outlineElem2 = new OutlineElement(doc)
            {
                NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
            };
            RichText text2 = new RichText(doc)
            {
                Text = "Second", DefaultStyle = defaultStyle
            };

            outlineElem2.AppendChild(text2);

            OutlineElement outlineElem3 = new OutlineElement(doc)
            {
                NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10)
            };
            RichText text3 = new RichText(doc)
            {
                Text = "Third", DefaultStyle = defaultStyle
            };

            outlineElem3.AppendChild(text3);

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

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

            dataDir = dataDir + "ApplyNumberingOnText_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:ApplyNumberingOnText
            Console.WriteLine("\nNumbering applied successfully on a text.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:InsertChineseNumberList
            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
            TextStyle defaultStyle = new TextStyle {
                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", DefaultStyle = defaultStyle
            };

            outlineElem1.AppendChild(text1);
            //------------------------
            OutlineElement outlineElem2 = new OutlineElement(doc)
            {
                NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
            };
            RichText text2 = new RichText(doc)
            {
                Text = "Second", DefaultStyle = defaultStyle
            };

            outlineElem2.AppendChild(text2);
            //------------------------
            OutlineElement outlineElem3 = new OutlineElement(doc)
            {
                NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
            };
            RichText text3 = new RichText(doc)
            {
                Text = "Third", DefaultStyle = defaultStyle
            };

            outlineElem3.AppendChild(text3);
            //------------------------
            outline.AppendChild(outlineElem1);
            outline.AppendChild(outlineElem2);
            outline.AppendChild(outlineElem3);
            page.AppendChild(outline);
            doc.AppendChild(page);

            dataDir = dataDir + "InsertChineseNumberList_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:InsertChineseNumberList
            Console.WriteLine("\nChinese number list inserted successfully.\nFile saved at " + dataDir);
        }
Exemplo n.º 16
0
        public static void Run()
        {
            // ExStart:CreateDocWithFormattedRichText
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

            // 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 Title class object
            Title title = new Title(doc);
            // Initialize TextStyle class object and set formatting properties
            TextStyle defaultTextStyle = new TextStyle
            {
                FontColor = Color.Black,
                FontName  = "Arial",
                FontSize  = 10
            };

            RichText titleText = new RichText(doc)
            {
                Text         = "Title!",
                DefaultStyle = defaultTextStyle
            };
            Outline outline = new Outline(doc)
            {
                VerticalOffset   = 100,
                HorizontalOffset = 100
            };
            OutlineElement outlineElem = new OutlineElement(doc);
            // RunIndex = 5 means the style will be applied only to 0-4 characters. ("Hello")
            TextStyle textStyleForHelloWord = new TextStyle
            {
                FontColor = Color.Red,
                FontName  = "Arial",
                FontSize  = 10,
                RunIndex  = 5,
            };
            // RunIndex = 13 means the style will be applied only to 5-12 characters. (" OneNote")
            TextStyle textStyleForOneNoteWord = new TextStyle
            {
                FontColor = Color.Green,
                FontName  = "Calibri",
                FontSize  = 10,
                IsItalic  = true,
                RunIndex  = 13,
            };
            // RunIndex = 18 means the style will be applied only to 13-17 characters. (" text").
            // Other characters ("!") will have the default style.
            TextStyle textStyleForTextWord = new TextStyle
            {
                FontColor = Color.Blue,
                FontName  = "Arial",
                FontSize  = 15,
                IsBold    = true,
                IsItalic  = true,
                RunIndex  = 18,
            };
            RichText text = new RichText(doc)
            {
                Text         = "Hello OneNote text!",
                DefaultStyle = defaultTextStyle,
                Styles       = { textStyleForHelloWord, textStyleForOneNoteWord, textStyleForTextWord }
            };

            title.TitleText = titleText;
            // Set page title
            page.Title = title;
            // Add RichText node
            outlineElem.AppendChild(text);
            // Add OutlineElement node
            outline.AppendChild(outlineElem);
            // Add Outline node
            page.AppendChild(outline);
            // Add Page node
            doc.AppendChild(page);

            dataDir = dataDir + "CreateDocWithFormattedRichText_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:CreateDocWithFormattedRichText
            Console.WriteLine("\nOneNote document created successfully with formatted rich text.\nFile saved at " + dataDir);
        }