Beispiel #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);
        }
Beispiel #4
0
        public static void CreateAndSavePageRange()
        {
            // ExStart:CreateAndSavePageRange
            // ExFor:Document
            // ExFor:Page
            // ExFor:Page.Title
            // ExFor:Title
            // ExFor:Title.TitleText
            // ExFor:Title.TitleDate
            // ExFor:Title.TitleTime
            // ExFor:RichText
            // ExFor:RichText.Text
            // ExFor:HtmlSaveOptions
            // ExFor:HtmlSaveOptions.PageCount
            // ExFor:HtmlSaveOptions.PageIndex
            // ExSummary:Shows how to create a document and save in html format specified range of pages.

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

            // Initialize OneNote document
            Document doc = new Document();

            Aspose.Note.Page page = new Aspose.Note.Page(doc);

            // Default style for all text in the document.
            ParagraphStyle textStyle = new ParagraphStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };

            page.Title = new Title(doc)
            {
                TitleText = new RichText(doc)
                {
                    Text = "Title text.", ParagraphStyle = textStyle
                },
                TitleDate = new RichText(doc)
                {
                    Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle
                },
                TitleTime = new RichText(doc)
                {
                    Text = "12:34", ParagraphStyle = textStyle
                }
            };
            doc.AppendChildLast(page);

            // Save as HTML format
            dataDir = dataDir + "CreateAndSavePageRange_out.html";
            doc.Save(dataDir, new HtmlSaveOptions
            {
                PageCount = 1,
                PageIndex = 0
            });

            // ExEnd:CreateAndSavePageRange

            Console.WriteLine("\nOneNote document created successfully and saved as page range.\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);
        }
Beispiel #6
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);
        }
Beispiel #7
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:CreateDocWithPageTitle
            // ExFor:Document
            // ExFor:Page
            // ExFor:Page.Title
            // ExFor:Title
            // ExFor:Title.TitleText
            // ExFor:Title.TitleDate
            // ExFor:Title.TitleTime
            // ExSummary:Shows how to create a document with titled page.

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

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

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

            // Default style for all text in the document.
            ParagraphStyle textStyle = new ParagraphStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };

            // Set page title properties
            page.Title = new Title(doc)
            {
                TitleText = new RichText(doc)
                {
                    Text = "Title text.", ParagraphStyle = textStyle
                },
                TitleDate = new RichText(doc)
                {
                    Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle
                },
                TitleTime = new RichText(doc)
                {
                    Text = "12:34", ParagraphStyle = textStyle
                }
            };

            // Append Page node in the document
            doc.AppendChildLast(page);

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

            // ExEnd:CreateDocWithPageTitle

            Console.WriteLine("\nOneNote document created successfully with page title.\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);
        }
Beispiel #10
0
        public static void Run()
        {
            // ExStart:ConsequentExportOperations
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

            // Initialize the new Document
            Document doc = new Document()
            {
                AutomaticLayoutChangesDetectionEnabled = false
            };

            // Initialize the new Page
            Aspose.Note.Page page = new Aspose.Note.Page(doc);
            // Default style for all text in the document.
            TextStyle textStyle = new TextStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };

            page.Title = new Title(doc)
            {
                TitleText = new RichText(doc)
                {
                    Text = "Title text.", DefaultStyle = textStyle
                },
                TitleDate = new RichText(doc)
                {
                    Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), DefaultStyle = textStyle
                },
                TitleTime = new RichText(doc)
                {
                    Text = "12:34", DefaultStyle = textStyle
                }
            };
            // Append page node
            doc.AppendChild(page);
            // Save OneNote document in the HTML format
            doc.Save("ConsequentExportOperations_out_.html");
            // Save OneNote document in the PDF format
            doc.Save("ConsequentExportOperations_out_.pdf");
            // Save OneNote document in the JPG format
            doc.Save("ConsequentExportOperations_out_.jpg");
            // Set text font size
            textStyle.FontSize = 11;
            // Detect layout changes manually
            doc.DetectLayoutChanges();
            // Save OneNote document in the BMP format
            doc.Save("ConsequentExportOperations_out_.bmp");
            // ExEnd:ConsequentExportOperations
            Console.WriteLine("\nConsequent export operations performed successfully.");
        }
        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);
        }
        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);
        }
Beispiel #13
0
        public static void Run()
        {
            // ExStart:SettingCellBackGroundColor
            // 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"));
            cell11.BackgroundColor = Color.Coral;
            row1.AppendChild(cell11);
            // ExEnd:SettingCellBackGroundColor
        }
        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);
        }
Beispiel #15
0
        public static void Run()
        {
            // ExStart:CreateOneNoteDocAndSaveToHTML
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_LoadingAndSaving();

            // Initialize OneNote document
            Document doc = new Document();

            Aspose.Note.Page page = new Aspose.Note.Page(doc);

            // Default style for all text in the document.
            TextStyle textStyle = new TextStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };

            page.Title = new Title(doc)
            {
                TitleText = new RichText(doc)
                {
                    Text = "Title text.", DefaultStyle = textStyle
                },
                TitleDate = new RichText(doc)
                {
                    Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), DefaultStyle = textStyle
                },
                TitleTime = new RichText(doc)
                {
                    Text = "12:34", DefaultStyle = textStyle
                }
            };
            doc.AppendChild(page);
            dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out_.html";
            // Save as HTML format
            doc.Save(dataDir);
            // ExEnd:CreateOneNoteDocAndSaveToHTML
            Console.WriteLine("\nOneNote document created 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: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);
        }
Beispiel #18
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:ApplyBulletsOnText
            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
            TextStyle defaultStyle = new TextStyle {
                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", DefaultStyle = defaultStyle
            };

            outlineElem1.AppendChild(text1);

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

            outlineElem2.AppendChild(text2);

            OutlineElement outlineElem3 = new OutlineElement(doc)
            {
                NumberList = new NumberList("*", "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 + "ApplyBulletsOnText_out.one";
            // Save OneNote document
            doc.Save(dataDir);
            // ExEnd:ApplyBulletsOnText
            Console.WriteLine("\nBullets applied successfully on a text.\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: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);
        }
        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);
        }
Beispiel #23
0
        public static void Run()
        {
            // ExStart:AddHyperlink
            // ExFor:Document
            // ExFor:RichText
            // ExFor:RichText.ParagraphStyle
            // ExFor:RichText.Styles
            // ExFor:RichText.Text
            // ExFor:TextStyle
            // ExFor:TextStyle.FontColor
            // ExFor:TextStyle.FontName
            // ExFor:TextStyle.FontSize
            // ExFor:TextStyle.RunIndex
            // 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(doc)
            {
                Text           = "Title!",
                ParagraphStyle = ParagraphStyle.Default
            };

            Outline outline = new Outline(doc)
            {
                MaxWidth         = 200,
                MaxHeight        = 200,
                VerticalOffset   = 100,
                HorizontalOffset = 100
            };

            TextStyle textStyleRed = new TextStyle
            {
                FontColor = Color.Red,
                FontName  = "Arial",
                FontSize  = 10,

                // This style will be applied to 0-7 characters.
                RunIndex = 8
            };

            TextStyle textStyleHyperlink = new TextStyle
            {
                // This style will be applied to 8-16 characters.
                RunIndex         = 17,
                IsHyperlink      = true,
                HyperlinkAddress = "www.google.com"
            };

            RichText text = new RichText(doc)
            {
                Text           = "This is hyperlink. This text is not a hyperlink.",
                ParagraphStyle = ParagraphStyle.Default,
                Styles         = { textStyleRed, textStyleHyperlink }
            };

            OutlineElement outlineElem = new OutlineElement(doc);

            outlineElem.AppendChildLast(text);

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

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

            // Initialize Page class object
            Aspose.Note.Page page = new Aspose.Note.Page(doc)
            {
                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);
        }
Beispiel #24
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:ConsequentExportOperations
            // ExFor:Document
            // ExFor:Document.AutomaticLayoutChangesDetectionEnabled
            // ExFor:Document.DetectLayoutChanges
            // ExFor:Page
            // ExFor:Page.Title
            // ExFor:Title
            // ExFor:Title.TitleText
            // ExFor:Title.TitleDate
            // ExFor:Title.TitleTime
            // ExSummary:Shows how to save a document in different formats.

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

            // Initialize the new Document
            Document doc = new Document()
            {
                AutomaticLayoutChangesDetectionEnabled = false
            };

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

            // Default style for all text in the document.
            ParagraphStyle textStyle = new ParagraphStyle {
                FontColor = Color.Black, FontName = "Arial", FontSize = 10
            };

            page.Title = new Title(doc)
            {
                TitleText = new RichText(doc)
                {
                    Text = "Title text.", ParagraphStyle = textStyle
                },
                TitleDate = new RichText(doc)
                {
                    Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture), ParagraphStyle = textStyle
                },
                TitleTime = new RichText(doc)
                {
                    Text = "12:34", ParagraphStyle = textStyle
                }
            };

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

            // Save OneNote document in different formats, set text font size and detect layout changes manually.
            doc.Save(dataDir + "ConsequentExportOperations_out.html");
            doc.Save(dataDir + "ConsequentExportOperations_out.pdf");
            doc.Save(dataDir + "ConsequentExportOperations_out.jpg");
            textStyle.FontSize = 11;
            doc.DetectLayoutChanges();
            doc.Save(dataDir + "ConsequentExportOperations_out.bmp");

            // ExEnd:ConsequentExportOperations

            Console.WriteLine("\nConsequent export operations performed successfully.");
        }