Exemple #1
0
        public static void Run()
        {
            // ExStart:SetDefaultParagraphStyle
            // ExFor:ParagraphStyle
            // ExFor:ParagraphStyle.FontName
            // ExFor:ParagraphStyle.FontSize
            // ExFor:RichText
            // ExFor:RichText.ParagraphStyle
            // ExFor:RichText.Text
            // ExFor:TextStyle
            // ExFor:TextStyle.FontName
            // ExFor:TextStyle.FontSize
            // ExSummary: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"));

            // ExEnd:SetDefaultParagraphStyle
        }
Exemple #2
0
        public static void Run()
        {
            // ExStart:AddTextNodeWithTag
            // ExFor:NoteTagCore
            // ExFor:NoteTagCore.Icon
            // ExFor:NoteTag
            // ExFor:RichText
            // ExFor:RichText.Text
            // ExFor:RichText.ParagraphStyle
            // ExSummary:Shows how to add new paragraph with tag.

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

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

            // Add text node
            outlineElem.AppendChildLast(text);

            // Add outline element node
            outline.AppendChildLast(outlineElem);

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

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

            // Save OneNote document
            dataDir = dataDir + "AddTextNodeWithTag_out.one";
            doc.Save(dataDir);

            // ExEnd:AddTextNodeWithTag

            Console.WriteLine("\nText node with tag added successfully.\nFile saved at " + dataDir);
        }
Exemple #3
0
        public static void Run()
        {
            // ExStart:SettingCellBackGroundColor
            // ExFor:Table
            // ExFor:Table.Columns
            // ExFor:Table.IsBordersVisible
            // ExFor:TableColumn
            // ExFor:TableColumn.Width
            // ExFor:TableRow
            // ExFor:TableCell
            // ExFor:TableCell.BackgroundColor
            // ExSummary:Shows how to set a background color for a cell.

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

            // Initialize TableCell class object and set text content
            TableCell cell11 = new TableCell(doc);

            cell11.AppendChildLast(InsertTable.GetOutlineElementWithText(doc, "Small text"));
            cell11.BackgroundColor = Color.Coral;

            // Initialize TableRow class object
            TableRow row = new TableRow(doc);

            row.AppendChildLast(cell11);

            Table table = new Table(doc)
            {
                IsBordersVisible = true,
                Columns          = { new TableColumn()
                                     {
                                         Width = 200
                                     } }
            };

            table.AppendChildLast(row);

            OutlineElement oe = new OutlineElement(doc);

            oe.AppendChildLast(table);

            Outline o = new Outline(doc);

            o.AppendChildLast(oe);

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

            page.AppendChildLast(o);

            doc.AppendChildLast(page);

            doc.Save(Path.Combine(RunExamples.GetDataDir_Tables(), "SettingCellBackGroundColor.pdf"));

            // ExEnd:SettingCellBackGroundColor
        }
Exemple #4
0
        public static void Run()
        {
            // ExStart:AddImageNodeWithTag
            // ExFor:Image
            // ExFor:Image.Tags
            // ExFor:NoteTagCore
            // ExFor:NoteTagCore.Icon
            // ExFor:NoteTag
            // ExFor:Page
            // ExFor:Outline
            // ExFor:OutlineElement
            // ExSummary:Shows how to add new image with tag.

            // 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.AppendChildLast(image);
            image.Tags.Add(new NoteTag
            {
                Icon = TagIcon.YellowStar,
            });

            // Add outline element node
            outline.AppendChildLast(outlineElem);

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

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

            // Save OneNote document
            dataDir = dataDir + "AddImageNodeWithTag_out.one";
            doc.Save(dataDir);

            // ExEnd:AddImageNodeWithTag

            Console.WriteLine("\nImage node with tag added successfully.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:CreateDocWithSimpleRichText
            // ExFor:Document
            // ExFor:RichText
            // ExFor:RichText.Text
            // ExSummary:Shows how to create a document with a text.

            // 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
            Page page = new 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
            ParagraphStyle textStyle = new ParagraphStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };

            // Initialize RichText class object and apply text style
            RichText text = new RichText(doc)
            {
                Text = "Hello OneNote text!", ParagraphStyle = textStyle
            };

            // Add RichText node
            outlineElem.AppendChildLast(text);

            // Add OutlineElement node
            outline.AppendChildLast(outlineElem);

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

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

            // Save OneNote document
            dataDir = dataDir + "CreateDocWithSimpleRichText_out.one";
            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
            // ExFor:Document
            // ExFor:Image
            // ExFor:Image.Alignment
            // ExSummary:Shows how to add an image from file to a document.

            // 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);

            // 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
                Alignment = HorizontalAlignment.Right
            };

            // Add image
            outlineElem.AppendChildLast(image);

            // Add outline elements
            outline.AppendChildLast(outlineElem);

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

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

            // Save OneNote document
            dataDir = dataDir + "BuildDocAndInsertImage_out.one";
            doc.Save(dataDir);

            // ExEnd:BuildDocAndInsertImage

            Console.WriteLine("\nDocument created and image inserted successfully.\nFile saved at " + dataDir);
        }
Exemple #7
0
        public static void Run()
        {
            // ExStart:AttachFileAndSetIcon
            // ExFor:Document
            // ExFor:AttachedFile
            // ExSummary:Shows how to add a file from a stream to a document.

            // 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);

            using (var stream = File.OpenRead(dataDir + "icon.jpg"))
            {
                // Initialize AttachedFile class object and also pass its icon path
                AttachedFile attachedFile = new AttachedFile(doc, dataDir + "attachment.txt", stream, ImageFormat.Jpeg);

                // Add attached file
                outlineElem.AppendChildLast(attachedFile);
            }

            // Add outline element node
            outline.AppendChildLast(outlineElem);

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

            // Add page node
            doc.AppendChildLast(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);
        }
Exemple #8
0
        public static void Run()
        {
            // ExStart:SetProofingLanguageForText
            // ExFor:TextStyle
            // ExFor:TextStyle.Language
            // ExFor:TextStyle.RunIndex
            // ExFor:RichText
            // ExFor:RichText.Styles
            // ExSummary:Set proofing language for a text.

            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 = "United States Germany China", ParagraphStyle = ParagraphStyle.Default
            };

            text.Styles.Add(new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("en-US"),
                RunIndex = 13
            });
            text.Styles.Add(new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("de-DE"),
                RunIndex = 21
            });
            text.Styles.Add(new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("zh-CN"),
                RunIndex = text.Text.Length
            });


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

            document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetProofingLanguageForText.one"));

            // ExEnd:SetProofingLanguageForText
        }
        public static void Run()
        {
            // ExStart:BuildDocAndInsertImageUsingImageStream
            // ExFor:Document
            // ExFor:Image
            // ExFor:Image.Alignment
            // ExSummary:Shows how to add an image from stream to a document.

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

            using (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
                    Alignment = HorizontalAlignment.Right
                };

                outlineElem1.AppendChildLast(image1);
            }

            outline1.AppendChildLast(outlineElem1);
            page.AppendChildLast(outline1);

            doc.AppendChildLast(page);

            // Save OneNote document
            dataDir = dataDir + "BuildDocAndInsertImageUsingImageStream_out.one";
            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:AttachFileByPath
            // ExFor:Document
            // ExFor:AttachedFile
            // ExSummary:Shows how to add a file to a document by using filepath.

            // 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.AppendChildLast(attachedFile);

            // Add outline element node
            outline.AppendChildLast(outlineElem);

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

            // Add page node
            doc.AppendChildLast(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:SetDefaultParagraphStyle
            // ExFor:ParagraphStyle
            // ExFor:RichText
            // ExFor:RichText.ParagraphStyle
            // ExFor:RichText.Append(System.String)
            // ExFor:RichText.Append(System.String,TextStyle)
            // ExFor:TextStyle
            // ExFor:Style.FontName
            // ExFor:Style.FontSize
            // ExSummary: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"));

            // ExEnd:SetDefaultParagraphStyle
        }
Exemple #12
0
        public static void Run()
        {
            // ExStart:SetProofingLanguageForText
            // ExFor:TextStyle
            // ExFor:TextStyle.Language
            // ExFor:RichText
            // ExFor:RichText.Append(System.String,TextStyle)
            // ExSummary:Set proofing language for a text.
            var document    = new Document();
            var page        = new Page();
            var outline     = new Outline();
            var outlineElem = new OutlineElement();

            var text = new RichText()
            {
                ParagraphStyle = ParagraphStyle.Default
            };

            text.Append("United States", new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("en-US")
            })
            .Append(" Germany", new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("de-DE")
            })
            .Append(" China", new TextStyle()
            {
                Language = CultureInfo.GetCultureInfo("zh-CN")
            });

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

            document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetProofingLanguageForText.one"));

            // ExEnd:SetProofingLanguageForText
        }
        public static void Run()
        {
            // ExStart:AddHyperlink
            // ExFor:Document
            // ExFor:RichText
            // ExFor:RichText.ParagraphStyle
            // ExFor:RichText.Text
            // ExFor:RichText.Append(System.String)
            // ExFor:RichText.Append(System.String,TextStyle)
            // ExFor:TextStyle
            // ExFor:Style.FontColor
            // ExFor:Style.FontName
            // ExFor:Style.FontSize
            // ExFor:TextStyle.IsHyperlink
            // ExFor:TextStyle.HyperlinkAddress
            // ExSummary:Shows how to bind a hyperlink to a text.

            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tasks();

            // Create an object of the Document class
            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);

            // Add outline elements
            outline.AppendChildLast(outlineElem);

            // Initialize Title class object
            Title title = new Title()
            {
                TitleText = titleText
            };

            // Initialize Page class object
            Page page = new Note.Page()
            {
                Title = title
            };

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

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

            // Save OneNote document
            dataDir = dataDir + "AddHyperlink_out.one";
            doc.Save(dataDir);

            // ExEnd:AddHyperlink

            Console.WriteLine("\nHyperlink added successfully.\nFile saved at " + dataDir);
        }
Exemple #14
0
        public static void Run()
        {
            // ExStart:AddTableNodeWithTag
            // ExFor:Table
            // ExFor:Table.Columns
            // ExFor:Table.IsBordersVisible
            // ExFor:TableColumn
            // ExFor:TableColumn.Width
            // ExFor:TableRow
            // ExFor:TableCell
            // ExFor:NoteTag
            // ExSummary:Shows how to add new table with tag.

            // 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.AppendChildLast(InsertTable.GetOutlineElementWithText(doc, "Single cell."));

            // Add cell to row node
            row.AppendChildLast(cell);

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

            // Insert row node in table
            table.AppendChildLast(row);

            // Add tag to this table node
            table.Tags.Add(NoteTag.CreateQuestionMark());

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

            // Add table node
            outlineElem.AppendChildLast(table);

            // Add outline elements
            outline.AppendChildLast(outlineElem);
            page.AppendChildLast(outline);
            doc.AppendChildLast(page);

            // Save OneNote document
            dataDir = dataDir + "AddTableNodeWithTag_out.one";
            doc.Save(dataDir);

            // ExEnd:AddTableNodeWithTag

            Console.WriteLine("\nTable node with tag added successfully.\nFile saved at " + dataDir);
        }
Exemple #15
0
        public static void Run()
        {
            // ExStart:CreateTableWithLockedColumns
            // ExFor:Table
            // ExFor:Table.Columns
            // ExFor:Table.IsBordersVisible
            // ExFor:TableColumn
            // ExFor:TableColumn.Width
            // ExFor:TableColumn.LockedWidth
            // ExFor:TableRow
            // ExFor:TableCell
            // ExSummary:Shows how to create a table with a locked column.

            // 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.AppendChildLast(InsertTable.GetOutlineElementWithText(doc, "Small text"));
            row1.AppendChildLast(cell11);

            // Initialize TableRow class object
            TableRow row2 = new TableRow(doc);

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

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

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

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

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

            // Add table node
            outlineElem.AppendChildLast(table);

            // Add outline element node
            outline.AppendChildLast(outlineElem);

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

            // Add page node
            doc.AppendChildLast(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:CreateDocWithFormattedRichText
            // ExFor:SaveOptions.PageIndex
            // ExFor:RichText.Append(System.String,TextStyle)
            // ExSummary:Shows how to create a document with formatted rich text.

            // 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
            Page page = new Page();

            // Initialize Title class object
            Title title = new Title();

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

            RichText titleText = new RichText()
            {
                ParagraphStyle = defaultTextStyle
            }.Append("Title!");
            Outline outline = new Outline()
            {
                VerticalOffset   = 100,
                HorizontalOffset = 100
            };
            OutlineElement outlineElem = new OutlineElement();

            TextStyle textStyleForHelloWord = new TextStyle
            {
                FontColor = Color.Red,
                FontName  = "Arial",
                FontSize  = 10,
            };

            TextStyle textStyleForOneNoteWord = new TextStyle
            {
                FontColor = Color.Green,
                FontName  = "Calibri",
                FontSize  = 10,
                IsItalic  = true,
            };

            TextStyle textStyleForTextWord = new TextStyle
            {
                FontColor = Color.Blue,
                FontName  = "Arial",
                FontSize  = 15,
                IsBold    = true,
                IsItalic  = true,
            };

            RichText text = new RichText()
            {
                ParagraphStyle = defaultTextStyle
            }
            .Append("Hello", textStyleForHelloWord)
            .Append(" OneNote", textStyleForOneNoteWord)
            .Append(" text", textStyleForTextWord)
            .Append("!", TextStyle.Default);

            title.TitleText = titleText;

            // Set page title
            page.Title = title;

            // Add RichText node
            outlineElem.AppendChildLast(text);

            // Add OutlineElement node
            outline.AppendChildLast(outlineElem);

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

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

            // Save OneNote document
            dataDir = dataDir + "CreateDocWithFormattedRichText_out.one";
            doc.Save(dataDir);

            // ExEnd:CreateDocWithFormattedRichText

            Console.WriteLine("\nOneNote document created successfully with formatted rich text.\nFile saved at " + dataDir);
        }
Exemple #17
0
        public static void Run()
        {
            // ExStart:CreateDocWithFormattedRichText
            // ExFor:ImageSaveOptions.PageIndex
            // ExSummary:Shows how to create a document with formatted rich text.

            // 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
            ParagraphStyle defaultTextStyle = new ParagraphStyle
            {
                FontColor = Color.Black,
                FontName  = "Arial",
                FontSize  = 10
            };

            RichText titleText = new RichText(doc)
            {
                Text           = "Title!",
                ParagraphStyle = 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!",
                ParagraphStyle = defaultTextStyle,
                Styles         = { textStyleForHelloWord, textStyleForOneNoteWord, textStyleForTextWord }
            };

            title.TitleText = titleText;

            // Set page title
            page.Title = title;

            // Add RichText node
            outlineElem.AppendChildLast(text);

            // Add OutlineElement node
            outline.AppendChildLast(outlineElem);

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

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

            // Save OneNote document
            dataDir = dataDir + "CreateDocWithFormattedRichText_out.one";
            doc.Save(dataDir);

            // ExEnd:CreateDocWithFormattedRichText

            Console.WriteLine("\nOneNote document created successfully with formatted rich text.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:CreateDocWithRootAndSubPages
            // ExFor:Page
            // ExFor:Page.Level
            // ExSummary:Shows how to add a page with a subpage.

            // 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);
            ParagraphStyle textStyle   = new ParagraphStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };
            RichText text = new RichText(doc)
            {
                Text = "First page.", ParagraphStyle = textStyle
            };

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

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

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

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

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

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

            // Save OneNote document
            dataDir = dataDir + "CreateDocWithRootAndSubPages_out.one";
            doc.Save(dataDir);

            // ExEnd:CreateDocWithRootAndSubPages

            Console.WriteLine("\nOneNote document created successfully with root and sub level pages.\nFile saved at " + dataDir);
        }
Exemple #19
0
        public static void Run()
        {
            // ExStart:InsertChineseNumberList
            // ExFor:NumberList
            // ExFor:ParagraphStyle
            // ExFor:ParagraphStyle.FontColor
            // ExFor:ParagraphStyle.FontName
            // ExFor:ParagraphStyle.FontSize
            // ExFor:Page
            // ExFor:Outline
            // ExFor:OutlineElement
            // ExFor:OutlineElement.NumberList
            // ExFor:RichText
            // ExFor:RichText.ParagraphStyle
            // ExFor:RichText.Text
            // ExSummary: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);

            // ExEnd:InsertChineseNumberList

            Console.WriteLine("\nChinese number list inserted successfully.\nFile saved at " + dataDir);
        }
Exemple #20
0
        public static void Run()
        {
            // ExStart:ApplyNumberingOnText
            // ExFor:NumberList
            // ExFor:ParagraphStyle
            // ExFor:ParagraphStyle.FontColor
            // ExFor:ParagraphStyle.FontName
            // ExFor:ParagraphStyle.FontSize
            // ExFor:Page
            // ExFor:Outline
            // ExFor:OutlineElement
            // ExFor:OutlineElement.NumberList
            // ExFor:RichText
            // ExFor:RichText.ParagraphStyle
            // ExFor:RichText.Text
            // ExSummary: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);

            // ExEnd:ApplyNumberingOnText

            Console.WriteLine("\nNumbering applied successfully on a text.\nFile saved at " + dataDir);
        }
        public static void Run()
        {
            // ExStart:InsertTable
            // ExFor:Table
            // ExFor:Table.Columns
            // ExFor:Table.IsBordersVisible
            // ExFor:TableColumn
            // ExFor:TableColumn.Width
            // ExFor:TableRow
            // ExFor:TableCell
            // ExSummary:Shows how to create a new table.

            // 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.AppendChildLast(GetOutlineElementWithText(doc, "cell_1.1"));
            cell12.AppendChildLast(GetOutlineElementWithText(doc, "cell_1.2"));
            cell13.AppendChildLast(GetOutlineElementWithText(doc, "cell_1.3"));

            // Table cells to rows
            row1.AppendChildLast(cell11);
            row1.AppendChildLast(cell12);
            row1.AppendChildLast(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.AppendChildLast(GetOutlineElementWithText(doc, "cell_2.1"));
            cell22.AppendChildLast(GetOutlineElementWithText(doc, "cell_2.2"));
            cell23.AppendChildLast(GetOutlineElementWithText(doc, "cell_2.3"));

            // Append table cells to rows
            row2.AppendChildLast(cell21);
            row2.AppendChildLast(cell22);
            row2.AppendChildLast(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.AppendChildLast(row1);
            table.AppendChildLast(row2);

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

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

            // Add table to outline element node
            outlineElem.AppendChildLast(table);

            // Add outline element to outline
            outline.AppendChildLast(outlineElem);

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

            // Add page to document node
            doc.AppendChildLast(page);
            dataDir = dataDir + "InsertTable_out.one";
            doc.Save(dataDir);

            // ExEnd:InsertTable

            Console.WriteLine("\nTable inserted successfully.\nFile saved at " + dataDir);
        }