Class Notebook

Class Notebook

Navne til: Aspose.Note Sammensætning: Aspose.Note.dll (25.4.0)

Det er en Aspose.Note notebook.

public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable

Inheritance

object Notebook

Implements

INotebookChildNode , IEnumerable , IEnumerable

De arvede medlemmer

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Se, hvordan man sparer en notebook.

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

                                      var notebook = new Notebook();

                                      dataDir = dataDir + "test_out.onetoc2";

                                      // Save the Notebook
                                      notebook.Save(dataDir);

Se, hvordan man gemmer en notebook i pdf-format.

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

                                                    // Load a OneNote Notebook
                                                    var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");

                                                    dataDir = dataDir + "ConvertToPDF_out.pdf";

                                                    // Save the Notebook
                                                    notebook.Save(dataDir);

Se, hvordan man gemmer en notebook som et billede.

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

                                               // Load a OneNote Notebook
                                               var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");

                                               dataDir = dataDir + "ConvertToImage_out.png";

                                               // Save the Notebook
                                               notebook.Save(dataDir);

Det viser, hvordan man får hele teksten fra en notebook.

string inputFile = "notebook.onetoc2";
                                                     string dataDir = RunExamples.GetDataDir_NoteBook();

                                                     Notebook rootNotebook = new Notebook(dataDir + inputFile);

                                                     IList<richtext> allRichTextNodes = rootNotebook.GetChildNodes<richtext>();
                                                     foreach (RichText richTextNode in allRichTextNodes)
                                                     {
                                                         Console.WriteLine(richTextNode.Text);
                                                     }</richtext></richtext>

Se, hvordan man gemmer en flatte notebook i pdf-format.

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

                                                              // Load a OneNote Notebook
                                                              var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");

                                                              // Save the Notebook
                                                              dataDir = dataDir + "ConvertToPDFAsFlattened_out.pdf";
                                                              notebook.Save(
                                                                  dataDir,
                                                                  new NotebookPdfSaveOptions
                                                                  {
                                                                      Flatten = true
                                                                  });

Det viser, hvordan man itererer gennem dokumenter fra en notebook, der lader dem lade.

string inputFile = "Notizbuch öffnen.onetoc2";
                                                                                    string dataDir = RunExamples.GetDataDir_NoteBook();

                                                                                    // By default children loading is "lazy".
                                                                                    Notebook notebook = new Notebook(dataDir + inputFile);

                                                                                    foreach (var notebookChildNode in notebook.OfType<document>()) 
                                                                                    {
                                                                                        // Actual loading of the child document happens only here.
                                                                                        // Do something with child document
                                                                                    }</document>

Se, hvordan du tilføjer en ny sektion til en notebook.

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

                                                      // Load a OneNote Notebook
                                                      var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");

                                                      // Append a new child to the Notebook
                                                      notebook.AppendChild(new Document(dataDir + "Neuer Abschnitt 1.one"));

                                                      dataDir = dataDir + "AddChildNode_out.onetoc2";

                                                      // Save the Notebook
                                                      notebook.Save(dataDir);

Se, hvordan man oplader en notebook fra en strøm.

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

                                                    FileStream stream = new FileStream(dataDir + "Notizbuch öffnen.onetoc2", FileMode.Open);

                                                    var notebook = new Notebook(stream);

                                                    using (FileStream childStream = new FileStream(dataDir + "Aspose.one", FileMode.Open))
                                                    {
                                                        notebook.LoadChildDocument(childStream);
                                                    }

                                                    notebook.LoadChildDocument(dataDir + "Sample1.one");

Det viser, hvordan man laver en krypteret notebook.

// The path to the documents directory.
                                              string dataDir = RunExamples.GetDataDir_NoteBook();
                                              var notebook = new Notebook(dataDir + "test.onetoc2", new NotebookLoadOptions() { DeferredLoading = true });

                                              notebook.LoadChildDocument(dataDir + "Aspose.one");  
                                              notebook.LoadChildDocument(dataDir + "Locked Pass1.one", new LoadOptions() { DocumentPassword = "pass" });
                                              notebook.LoadChildDocument(dataDir + "Locked Pass2.one", new LoadOptions() { DocumentPassword = "pass2" });

Se, hvordan man gemmer en notebook som et billede med angivne muligheder.

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

                                                                      // Load a OneNote Notebook
                                                                      var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");

                                                                      var notebookSaveOptions = new NotebookImageSaveOptions(SaveFormat.Png);

                                                                      var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;

                                                                      documentSaveOptions.Resolution = 400;

                                                                      dataDir = dataDir + "ConvertToImageWithOptions_out.png";

                                                                      // Save the Notebook
                                                                      notebook.Save(dataDir, notebookSaveOptions);

Det viser, hvordan man gemmer en flatte notebook som et billede.

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

                                                         // Load a OneNote Notebook
                                                         var notebook = new Notebook(dataDir + "Notizbuch öffnen.onetoc2");

                                                         var notebookSaveOptions = new NotebookImageSaveOptions(SaveFormat.Png);

                                                         var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;

                                                         documentSaveOptions.Resolution = 400;
                                                         notebookSaveOptions.Flatten = true;

                                                         dataDir = dataDir + "ConvertToImageAsFlattenedNotebook_out.png";

                                                         // Save the Notebook
                                                         notebook.Save(dataDir, notebookSaveOptions);

Se, hvordan man fjerner en sektion fra en notebook.

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

                                                         // Load a OneNote Notebook
                                                         var notebook = new Notebook(dataDir + "test.onetoc2");

                                                         // Traverse through its child nodes for searching the desired child item
                                                         foreach (var child in new List<inotebookchildnode>(notebook))
                                                         {
                                                             if (child.DisplayName == "Remove Me")
                                                             {
                                                                 // Remove the Child Item from the Notebook
                                                                 notebook.RemoveChild(child);
                                                             }
                                                         }

                                                         dataDir = dataDir + "RemoveChildNode_out.onetoc2";

                                                         // Save the Notebook
                                                         notebook.Save(dataDir);</inotebookchildnode>

Det viser, hvordan man itererer gennem forladte dokumenter fra en notebook.

// By default children loading is "lazy".
                                                                          // Therefore for instant loading has took place,
                                                                          // it is necessary to set the NotebookLoadOptions.InstantLoading flag.
                                                                          NotebookLoadOptions loadOptions = new NotebookLoadOptions { InstantLoading = true };

                                                                          String inputFile = "Notizbuch öffnen.onetoc2";
                                                                          String dataDir = RunExamples.GetDataDir_NoteBook();
                                                                          Notebook notebook = new Notebook(dataDir + inputFile, loadOptions);

                                                                          // All child documents are already loaded.
                                                                          foreach (INotebookChildNode notebookChildNode in notebook.OfType<document>()) 
                                                                          {
                                                                             // Do something with child document
                                                                          }</document>

Det viser, hvordan man passerer gennem indholdet af en notebook.

// The path to the documents directory.
                                                           string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
                                                           string fileName = "Open Notebook.onetoc2";
                                                           try
                                                           {
                                                               var notebook = new Notebook(dataDir + fileName);
                                                               foreach (var notebookChildNode in notebook)
                                                               {
                                                                   Console.WriteLine(notebookChildNode.DisplayName);
                                                                   if (notebookChildNode is Document)
                                                                   {
                                                                       // Do something with child document
                                                                   }
                                                                   else if (notebookChildNode is Notebook)
                                                                   {
                                                                       // Do something with child notebook
                                                                   }
                                                               }
                                                           }
                                                           catch (Exception ex)
                                                           {
                                                               Console.WriteLine(ex.Message);
                                                           }

Constructors

Notebook()

Initialiserer en ny instans af Aspose.Note.Notebook klasse.

public Notebook()

Notebook(String)

Initialiserer en ny instans af Aspose.Note.Notebook klasse.Åbner en eksisterende OneNote notebook fra en fil.

public Notebook(string filePath)

Parameters

filePath string

filen vej til.

Notebook(Læge, NotebookLoadOptions)

Initialiserer en ny instans af Aspose.Note.Notebook klasse.Åbner en eksisterende OneNote notebook fra en fil. Tillader at angive yderligere muligheder som en børneopladningsstrategi (“lazy”/instant).

public Notebook(string filePath, NotebookLoadOptions loadOptions)

Parameters

filePath string

filen vej til.

loadOptions NotebookLoadOptions

Optioner for belastning.

Notebook(Stream)

Initialiserer en ny instans af Aspose.Note.Notebook klasse.Åbner en eksisterende OneNote notebook fra en strøm.

public Notebook(Stream stream)

Parameters

stream Stream

og strømmen.

Notebook(Billeder, NotebookLoadOptions)

Initialiserer en ny instans af Aspose.Note.Notebook klasse.Åbner en eksisterende OneNote notebook fra en strøm. Tillader at angive yderligere opladningsmuligheder.

public Notebook(Stream stream, NotebookLoadOptions loadOptions)

Parameters

stream Stream

og strømmen.

loadOptions NotebookLoadOptions

Optioner for belastning.

Properties

Color

Giver eller sætter farven.

public Color Color { get; set; }

Ejendomsværdi

Color

Count

Få det antal elementer, der er indeholdt i Aspose.Note.Notebook.

public int Count { get; }

Ejendomsværdi

int

DisplayName

Få eller indsæt displaynavnet.

public string DisplayName { get; set; }

Ejendomsværdi

string

Examples

Se, hvordan man fjerner en sektion fra en notebook.

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

                                                         // Load a OneNote Notebook
                                                         var notebook = new Notebook(dataDir + "test.onetoc2");

                                                         // Traverse through its child nodes for searching the desired child item
                                                         foreach (var child in new List<inotebookchildnode>(notebook))
                                                         {
                                                             if (child.DisplayName == "Remove Me")
                                                             {
                                                                 // Remove the Child Item from the Notebook
                                                                 notebook.RemoveChild(child);
                                                             }
                                                         }

                                                         dataDir = dataDir + "RemoveChildNode_out.onetoc2";

                                                         // Save the Notebook
                                                         notebook.Save(dataDir);</inotebookchildnode>

FileFormat

Få filformatet (OneNote 2010, OneNota Online).

public FileFormat FileFormat { get; }

Ejendomsværdi

FileFormat

Guid

Får objekts globalt unikke ID.

public Guid Guid { get; }

Ejendomsværdi

Guid

IsHistoryEnabled

Giver eller sætter en værdi, der angiver, om historien er aktiveret.

public bool IsHistoryEnabled { get; set; }

Ejendomsværdi

bool

Dette[Int]

Gør barnets notebook-node af den angivne indeks.

public INotebookChildNode this[int index] { get; }

Ejendomsværdi

INotebookChildNode

Methods

AppendChild(AnmeldelseChildNode)

Tilføj knuden til slutningen af listen.

public INotebookChildNode AppendChild(INotebookChildNode newChild)

Parameters

newChild INotebookChildNode

Node til at tilføje.

Returns

INotebookChildNode

Den tilføjede node.

Skærme()

Få alle barnets knuder efter knudetypen.

public IList<t1> GetChildNodes<t1>() where T1 : Node

Returns

IList

En liste over børns knuder.

Typer af parametre

T1

Typen af elementer i den returnerede liste.

GetEnumerator()

Returnerer en enumerator, der itererer gennem barnets knuder af Aspose.Note.Notebook.

public IEnumerator<inotebookchildnode> GetEnumerator()

Returns

IEnumerator < INotebookChildNode >

Et system. Kollektioner.IEnumerator

LoadChildDocument(String)

Tilføj en børnedokument node.Åbn et eksisterende OneNote-dokument fra en fil.

public void LoadChildDocument(string filePath)

Parameters

filePath string

filen vej til.

Examples

Se, hvordan man oplader en notebook fra en strøm.

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

                                                    FileStream stream = new FileStream(dataDir + "Notizbuch öffnen.onetoc2", FileMode.Open);

                                                    var notebook = new Notebook(stream);

                                                    using (FileStream childStream = new FileStream(dataDir + "Aspose.one", FileMode.Open))
                                                    {
                                                        notebook.LoadChildDocument(childStream);
                                                    }

                                                    notebook.LoadChildDocument(dataDir + "Sample1.one");

LoadChildDocument(String og LoadOptions)

Tilføj en børnedokument node.Åbner et eksisterende OneNote-dokument fra en fil. giver mulighed for at angive yderligere lademuligheder.

public void LoadChildDocument(string filePath, LoadOptions loadOptions)

Parameters

filePath string

filen vej til.

loadOptions LoadOptions

Optioner for belastning.

LoadChildDocument(Stream)

Tilføj en børnedokument node.Åbn et eksisterende OneNote-dokument fra en strøm.

public void LoadChildDocument(Stream stream)

Parameters

stream Stream

og strømmen.

Examples

Se, hvordan man oplader en notebook fra en strøm.

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

                                                    FileStream stream = new FileStream(dataDir + "Notizbuch öffnen.onetoc2", FileMode.Open);

                                                    var notebook = new Notebook(stream);

                                                    using (FileStream childStream = new FileStream(dataDir + "Aspose.one", FileMode.Open))
                                                    {
                                                        notebook.LoadChildDocument(childStream);
                                                    }

                                                    notebook.LoadChildDocument(dataDir + "Sample1.one");

LoadChildDocument(Strøm, LoadOptions)

Tilføj en børnedokument node.Åbner et eksisterende OneNote-dokument fra en strøm. Tillader at angive yderligere opladningsmuligheder.

public void LoadChildDocument(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

og strømmen.

loadOptions LoadOptions

Optioner for belastning.

LoadChildNotebook(String)

Tilføj et barns notebook-node.Åbner en eksisterende OneNote notebook fra en fil.

public void LoadChildNotebook(string filePath)

Parameters

filePath string

filen vej til.

LoadChildNotebook(Læge, NotebookLoadOptions)

Tilføj et barns notebook-node.Åbner en eksisterende OneNote notebook fra en fil. Tillader at angive yderligere lademuligheder.

public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)

Parameters

filePath string

filen vej til.

loadOptions NotebookLoadOptions

Optioner for belastning.

LoadChildNotebook(Stream)

Tilføj et barns notebook-node.Åbner en eksisterende OneNote notebook fra en strøm.

public void LoadChildNotebook(Stream stream)

Parameters

stream Stream

og strømmen.

LoadChildNotebook(Billeder, NotebookLoadOptions)

Tilføj et barns notebook-node.Åbner en eksisterende OneNote notebook fra en strøm. Tillader at angive yderligere opladningsmuligheder.

public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)

Parameters

stream Stream

og strømmen.

loadOptions NotebookLoadOptions

Optioner for belastning.

RemoveChild(AnmeldelseChildNode)

Fjern barnets knude.

public INotebookChildNode RemoveChild(INotebookChildNode oldChild)

Parameters

oldChild INotebookChildNode

Noden skal fjernes.

Returns

INotebookChildNode

Den fjernet node.

Examples

Se, hvordan du kan få adgang til alle sektioner fra en notebook.

string inputFile = "notebook.onetoc2";
                                                            string dataDir = RunExamples.GetDataDir_NoteBook();

                                                            Notebook rootNotebook = new Notebook(dataDir + inputFile);

                                                            IList<document> allDocuments = rootNotebook.GetChildNodes<document>();
                                                            foreach (Document document in allDocuments) 
                                                            {
                                                                Console.WriteLine(document.DisplayName);
                                                            }</document></document>

Se, hvordan man fjerner en sektion fra en notebook.

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

                                                         // Load a OneNote Notebook
                                                         var notebook = new Notebook(dataDir + "test.onetoc2");

                                                         // Traverse through its child nodes for searching the desired child item
                                                         foreach (var child in new List<inotebookchildnode>(notebook))
                                                         {
                                                             if (child.DisplayName == "Remove Me")
                                                             {
                                                                 // Remove the Child Item from the Notebook
                                                                 notebook.RemoveChild(child);
                                                             }
                                                         }

                                                         dataDir = dataDir + "RemoveChildNode_out.onetoc2";

                                                         // Save the Notebook
                                                         notebook.Save(dataDir);</inotebookchildnode>

Det viser, hvordan man sparer en notebook.

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

                                        var notebook = new Notebook(dataDir + "test.onetoc2", new NotebookLoadOptions() { DeferredLoading = false });

                                        notebook.Save(dataDir + "notebook_out.onetoc2", new NotebookOneSaveOptions() { DeferredSaving = true});

                                        if (notebook.Any())
                                        {
                                            var childDocument0 = notebook[0] as Document;

                                            childDocument0.Save(dataDir + "Not Locked_out.one");

                                            var childDocument1 = notebook[1] as Document;

                                            childDocument1.Save(dataDir + "Locked Pass1_out.one", new OneSaveOptions() { DocumentPassword = "pass" });

                                            var childDocument2 = notebook[2] as Document;

                                            childDocument2.Save(dataDir + "Locked Pass2_out.one", new OneSaveOptions() { DocumentPassword = "pass2" });
                                        }

Save(String)

Spare OneNote-dokumentet til en fil.

public void Save(string fileName)

Parameters

fileName string

Hvis en fil med det angivne fulde navn allerede eksisterer, overskrives den eksisterende fil.

Exceptions

IncorrectDocumentStructureException

Dokumentstrukturen krænker specifikationen.

UnsupportedSaveFormatException

Det anmodede redigeringsformat understøttes ikke.

Save(Stream)

Spare OneNote-dokumentet til en strøm.

public void Save(Stream stream)

Parameters

stream Stream

og strømmen.

Exceptions

IncorrectDocumentStructureException

Dokumentstrukturen krænker specifikationen.

UnsupportedSaveFormatException

Det anmodede redigeringsformat understøttes ikke.

Save(String og SaveFormat)

Spare OneNote-dokumentet til en fil i det angivne format.

public void Save(string fileName, SaveFormat format)

Parameters

fileName string

Hvis en fil med det angivne fulde navn allerede eksisterer, overskrives den eksisterende fil.

format SaveFormat

Formatet, hvor dokumentet skal gemmes.

Exceptions

IncorrectDocumentStructureException

Dokumentstrukturen krænker specifikationen.

UnsupportedSaveFormatException

Det anmodede redigeringsformat understøttes ikke.

Save(Skærm, SaveFormat)

Sparer OneNote-dokumentet til en strøm i det angivne format.

public void Save(Stream stream, SaveFormat format)

Parameters

stream Stream

og strømmen.

format SaveFormat

Formatet, hvor dokumentet skal gemmes.

Exceptions

IncorrectDocumentStructureException

Dokumentstrukturen krænker specifikationen.

UnsupportedSaveFormatException

Det anmodede redigeringsformat understøttes ikke.

Save(Forkort, NotebookSaveOptions)

Sparer OneNote-dokumentet til en fil ved hjælp af de angivne sparingsmuligheder.

public void Save(string fileName, NotebookSaveOptions options)

Parameters

fileName string

Hvis en fil med det angivne fulde navn allerede eksisterer, overskrives den eksisterende fil.

options NotebookSaveOptions

Det angiver mulighederne for, hvordan dokumentet gemmes i filen.

Exceptions

IncorrectDocumentStructureException

Dokumentstrukturen krænker specifikationen.

UnsupportedSaveFormatException

Det anmodede redigeringsformat understøttes ikke.

Save(Billeder, NotebookSaveOptions)

Sparer OneNote-dokumentet til en strøm ved hjælp af de angivne sparingsmuligheder.

public void Save(Stream stream, NotebookSaveOptions options)

Parameters

stream Stream

og strømmen.

options NotebookSaveOptions

Det angiver mulighederne for, hvordan dokumentet gemmes.

Exceptions

IncorrectDocumentStructureException

Dokumentstrukturen krænker specifikationen.

UnsupportedSaveFormatException

Det anmodede redigeringsformat understøttes ikke.

 Dansk