public static void Run()
        {
            // ExStart:RetrievingFileFormat
            // ExFor:Document
            // ExFor:Document.FileFormat
            // ExSummary:Shows how to get file format of a document.

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

            var document = new Aspose.Note.Document(dataDir + "Aspose.one");

            switch (document.FileFormat)
            {
            case FileFormat.OneNote2010:
                // Process OneNote 2010
                break;

            case FileFormat.OneNoteOnline:
                // Process OneNote Online
                break;
            }

            // ExEnd:RetrievingFileFormat
        }
Beispiel #2
0
        public static void SaveAsHTMLToFileWithResourcesInSeparateFiles()
        {
            // ExStart: SaveAsHTMLWithResourcesInSeparateFiles
            // ExFor:Document
            // ExFor:HtmlSaveOptions
            // ExFor:HtmlSaveOptions.ExportCss
            // ExFor:HtmlSaveOptions.ExportFonts
            // ExFor:HtmlSaveOptions.ExportImages
            // ExFor:HtmlSaveOptions.FontFaceTypes
            // ExSummary:Shows how to save a document in html format with storing all resources(css/fonts/images) to a separate files.
            string dataDir  = RunExamples.GetDataDir_LoadingAndSaving();
            var    document = new Aspose.Note.Document(dataDir + "Aspose.one");

            var options = new HtmlSaveOptions()
            {
                ExportCss     = ResourceExportType.ExportAsStream,
                ExportFonts   = ResourceExportType.ExportAsStream,
                ExportImages  = ResourceExportType.ExportAsStream,
                FontFaceTypes = FontFaceType.Ttf
            };

            document.Save(dataDir + "document_out.html", options);

            // ExEnd: SaveAsHTMLWithResourcesInSeparateFiles
        }
Beispiel #3
0
        public static void SaveAsHTMLToMemoryStreamWithEmbeddedResources()
        {
            // ExStart: SaveAsHTMLToMemoryStream
            // ExFor:Document
            // ExFor:HtmlSaveOptions
            // ExFor:HtmlSaveOptions.ExportCss
            // ExFor:HtmlSaveOptions.ExportFonts
            // ExFor:HtmlSaveOptions.ExportImages
            // ExFor:HtmlSaveOptions.FontFaceTypes
            // ExSummary:Shows how to save a document to a stream in html format with embedding of all resources(css/fonts/images).

            string dataDir  = RunExamples.GetDataDir_LoadingAndSaving();
            var    document = new Aspose.Note.Document(dataDir + "Aspose.one");

            var options = new HtmlSaveOptions()
            {
                ExportCss     = ResourceExportType.ExportEmbedded,
                ExportFonts   = ResourceExportType.ExportEmbedded,
                ExportImages  = ResourceExportType.ExportEmbedded,
                FontFaceTypes = FontFaceType.Ttf
            };

            var r = new MemoryStream();

            document.Save(r, options);

            // ExEnd: SaveAsHTMLToMemoryStream
        }
        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 Response UnlockNote(string fileName, string folderName, string password)
 {
     Aspose.Note.Live.Demos.UI.Models.License.SetAsposeNoteLicense();
     return(Process(GetType().Name, fileName, folderName, ".one", false, false,
                    "UnlockNote",
                    (inFilePath, outPath, zipOutFolder) =>
     {
         Aspose.Note.Document doc = new Aspose.Note.Document(inFilePath, new Aspose.Note.LoadOptions()
         {
             DocumentPassword = password
         });
         doc.Save(outPath);
     }));
 }
Beispiel #6
0
        public static void SaveAsHTMLToMemoryStreamWithCallBacksToSaveResources()
        {
            // ExStart: SaveAsHTMLToMemoryStreamWithCallBacksToSaveResources
            // ExFor:Document
            // ExFor:HtmlSaveOptions
            // ExFor:HtmlSaveOptions.CssSavingCallback
            // ExFor:HtmlSaveOptions.FontSavingCallback
            // ExFor:HtmlSaveOptions.ImageSavingCallback
            // ExFor:HtmlSaveOptions.FontFaceTypes
            // ExSummary:Shows how to save a document in html format with storing all resources(css/fonts/images) by using user defined callbacks.

            // This code creates documentFolder containing document.html, css folder with style.css file, images folder with images and fonts folder with fonts.
            // style.css file will contains at the end the following string "/* This line is appended to stream manually by user */"
            var savingCallbacks = new UserSavingCallbacks()
            {
                RootFolder          = "documentFolder",
                CssFolder           = "css",
                KeepCssStreamOpened = true,
                ImagesFolder        = "images",
                FontsFolder         = "fonts"
            };
            var options = new HtmlSaveOptions
            {
                FontFaceTypes       = FontFaceType.Ttf,
                CssSavingCallback   = savingCallbacks,
                FontSavingCallback  = savingCallbacks,
                ImageSavingCallback = savingCallbacks
            };

            if (!Directory.Exists(savingCallbacks.RootFolder))
            {
                Directory.CreateDirectory(savingCallbacks.RootFolder);
            }

            string dataDir  = RunExamples.GetDataDir_LoadingAndSaving();
            var    document = new Aspose.Note.Document(dataDir + "Aspose.one");

            using (var stream = File.Create(Path.Combine(savingCallbacks.RootFolder, "document.html")))
            {
                document.Save(stream, options);
            }

            using (var writer = new StreamWriter(savingCallbacks.CssStream))
            {
                writer.WriteLine();
                writer.WriteLine("/* This line is appended to stream manually by user */");
            }

            // ExEnd: SaveAsHTMLToMemoryStreamWithCallBacksToSaveResources
        }
        public static void SaveAsHTMLToFileWithResourcesInSeparateFiles()
        {
            //ExStart: SaveAsHTMLWithResourcesInSeparateFiles
            string dataDir  = RunExamples.GetDataDir_LoadingAndSaving();
            var    document = new Aspose.Note.Document(dataDir + "Aspose.one");

            var options = new HtmlSaveOptions()
            {
                ExportCss     = ResourceExportType.ExportAsFile,
                ExportFonts   = ResourceExportType.ExportAsFile,
                ExportImages  = ResourceExportType.ExportAsFile,
                FontFaceTypes = FontFaceType.Ttf
            };

            document.Save(dataDir + "document_out.html", options);
            //ExEnd: SaveAsHTMLWithResourcesInSeparateFiles
        }
        public static void SaveAsHTMLToMemoryStreamWithEmbeddedResources()
        {
            //ExStart: SaveAsHTMLToMemoryStream
            string dataDir  = RunExamples.GetDataDir_LoadingAndSaving();
            var    document = new Aspose.Note.Document(dataDir + "Aspose.one");

            var options = new HtmlSaveOptions()
            {
                ExportCss     = ResourceExportType.ExportEmbedded,
                ExportFonts   = ResourceExportType.ExportEmbedded,
                ExportImages  = ResourceExportType.ExportEmbedded,
                FontFaceTypes = FontFaceType.Ttf
            };
            var r = new MemoryStream();

            document.Save(r, options);
            //ExEnd: SaveAsHTMLToMemoryStream
        }
        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: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);
        }