Class Notebook

Class Notebook

Nom dels espais: Aspose.Note Assemblea: Aspose.Note.dll (25.4.0)

Representa un WL31_ notebook.

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

Inheritance

object Notebook

Implements

INotebookChildNode , IEnumerable , IEnumerable

Membres heretats

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

Examples

Mostra com salvar el 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);

Mostra com guardar el notebook en format PDF.

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

Mostra com salvar el notebook com a imatge.

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

Mostra com obtenir tot el text d’un 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>

Mostra com guardar un notebook flatenat en format PDF.

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

Mostra com iterar a través de documents d’un notebook que els carrega lleugerament.

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>

Mostra com afegir una nova secció a un 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);

Mostra com carregar el notebook d’un corrent.

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

Mostra com fer un notebook xifrat.

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

Mostra com salvar el notebook com a imatge amb les opcions especificades.

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

Mostra com guardar un notebook flatulent com a imatge.

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

Mostra com eliminar una secció d’un 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>

Mostra com iterar a través de documents precarregats d’un 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>

Mostra com passar pel contingut d’un 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()

Inicialitza una nova instància de la classe Aspose.Note.Notebook.

public Notebook()

Notebook(Tàrrega)

Inicialitza una nova instància de la classe Aspose.Note.Notebook.Obre un notebook de OneNote existent d’un arxiu.

public Notebook(string filePath)

Parameters

filePath string

El camí del fitxer.

Notebook(Llista de notícies, NotebookLoadOptions)

Inicialitza una nova instància de la classe Aspose.Note.Notebook.Obre un notebook OneNote existent des d’un arxiu. permet especificar opcions addicionals com una estratègia de càrrega infantil (“lazy” / instant).

public Notebook(string filePath, NotebookLoadOptions loadOptions)

Parameters

filePath string

El camí del fitxer.

loadOptions NotebookLoadOptions

Opcions de càrrega.

Notebook(Stream)

Inicialitza una nova instància de la classe Aspose.Note.Notebook.Obre un notebook OneNote existent des d’un corrent.

public Notebook(Stream stream)

Parameters

stream Stream

El corrent.

Notebook(Llista de notícies, NotebookLoadOptions)

Inicialitza una nova instància de la classe Aspose.Note.Notebook.Obre un notebook OneNote existent des d’un corrent. permet especificar opcions de càrrega addicionals.

public Notebook(Stream stream, NotebookLoadOptions loadOptions)

Parameters

stream Stream

El corrent.

loadOptions NotebookLoadOptions

Opcions de càrrega.

Properties

Color

Obtenir o posar el color.

public Color Color { get; set; }

Valor de la propietat

Color

Count

Obté el nombre d’elements continguts en el Aspose.Note.Notebook.

public int Count { get; }

Valor de la propietat

int

DisplayName

Obtenir o posar el nom de la pantalla.

public string DisplayName { get; set; }

Valor de la propietat

string

Examples

Mostra com eliminar una secció d’un 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

Obté el format de fitxers (OneNote 2010, OneNota Online).

public FileFormat FileFormat { get; }

Valor de la propietat

FileFormat

Guid

Obté l’ID globalment únic de l’objecte.

public Guid Guid { get; }

Valor de la propietat

Guid

IsHistoryEnabled

Obté o s’estableix un valor que indiqui si l’història està activada.

public bool IsHistoryEnabled { get; set; }

Valor de la propietat

bool

Aquest[Int]

Obté el nucli infantil de la notable per l’índex donat.

public INotebookChildNode this[int index] { get; }

Valor de la propietat

INotebookChildNode

Methods

AppendChild(Títol: INOTEBOOK)

Afegeix el nucli al final de la llista.

public INotebookChildNode AppendChild(INotebookChildNode newChild)

Parameters

newChild INotebookChildNode

El nucli per afegir.

Returns

INotebookChildNode

El nucli afegit.

Càlculs ()

Obtenir tots els nodes infantils pel tipus de nucli.

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

Returns

IList

Una llista de nodes infantils.

Tipus de paràmetres

T1

El tipus d’elements de la llista retornada.

GetEnumerator()

Retorna un enumerador que itera a través dels nodes infantils del Aspose.Note.Notebook.

public IEnumerator<inotebookchildnode> GetEnumerator()

Returns

IEnumerator < INotebookChildNode >

Un sistema.Col·leccions.IEnumerador

LoadChildDocument(Tàrrega)

Afegeix un nucli de document infantil.Obre un document OneNote existent d’un arxiu.

public void LoadChildDocument(string filePath)

Parameters

filePath string

El camí del fitxer.

Examples

Mostra com carregar el notebook d’un corrent.

// 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(Lloc, Lloc Opcions)

Afegeix un nucli de document infantil.Obre un document OneNote existent d’un arxiu. permet especificar opcions de càrrega addicionals.

public void LoadChildDocument(string filePath, LoadOptions loadOptions)

Parameters

filePath string

El camí del fitxer.

loadOptions LoadOptions

Opcions de càrrega.

LoadChildDocument(Stream)

Afegeix un nucli de document infantil.Obre un document OneNote existent des d’un corrent.

public void LoadChildDocument(Stream stream)

Parameters

stream Stream

El corrent.

Examples

Mostra com carregar el notebook d’un corrent.

// 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(Projecció, LoadOptions)

Afegeix un nucli de document infantil.Obre un document OneNote existent des d’un flux. permet especificar opcions de càrrega addicionals.

public void LoadChildDocument(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

El corrent.

loadOptions LoadOptions

Opcions de càrrega.

LoadChildNotebook(Tàrrega)

Afegeix un núvol de notebook infantil.Obre un notebook de OneNote existent d’un arxiu.

public void LoadChildNotebook(string filePath)

Parameters

filePath string

El camí del fitxer.

LoadChildNotebook(Llista de notícies, NotebookLoadOptions)

Afegeix un núvol de notebook infantil.Obre un notebook OneNote existent des d’un arxiu. permet especificar opcions de càrrega addicionals.

public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)

Parameters

filePath string

El camí del fitxer.

loadOptions NotebookLoadOptions

Opcions de càrrega.

LoadChildNotebook(Stream)

Afegeix un núvol de notebook infantil.Obre un notebook OneNote existent des d’un corrent.

public void LoadChildNotebook(Stream stream)

Parameters

stream Stream

El corrent.

LoadChildNotebook(Llista de notícies, NotebookLoadOptions)

Afegeix un núvol de notebook infantil.Obre un notebook OneNote existent des d’un corrent. permet especificar opcions de càrrega addicionals.

public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)

Parameters

stream Stream

El corrent.

loadOptions NotebookLoadOptions

Opcions de càrrega.

RemoveChild(Títol: INOTEBOOK)

Elimina el nucli del nen.

public INotebookChildNode RemoveChild(INotebookChildNode oldChild)

Parameters

oldChild INotebookChildNode

El nucli per eliminar.

Returns

INotebookChildNode

El nucli eliminat.

Examples

Mostra com accedir a totes les seccions d’un 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>

Mostra com eliminar una secció d’un 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>

Mostra com salvar un 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(Tàrrega)

Salva el document OneNote a un arxiu.

public void Save(string fileName)

Parameters

fileName string

Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Save(Stream)

Salva el document OneNote a un flux.

public void Save(Stream stream)

Parameters

stream Stream

El corrent.

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Save(Títol, SaveFormat)

Salva el document OneNote a un arxiu en el format especificat.

public void Save(string fileName, SaveFormat format)

Parameters

fileName string

Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.

format SaveFormat

El format en el qual guardar el document.

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Save(Arxiu, SaveFormat)

Salva el document OneNote a un flux en el format especificat.

public void Save(Stream stream, SaveFormat format)

Parameters

stream Stream

El corrent.

format SaveFormat

El format en el qual guardar el document.

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Save(Llistat, NotebookSaveOptions)

Salva el document OneNote a un arxiu utilitzant les opcions especificades.

public void Save(string fileName, NotebookSaveOptions options)

Parameters

fileName string

Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.

options NotebookSaveOptions

Especifica les opcions de com s’emmagatzema el document en el fitxer.

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

Save(Projecció, NotebookSaveOptions)

Salva el document de OneNote a un flux utilitzant les opcions especificades de salvatge.

public void Save(Stream stream, NotebookSaveOptions options)

Parameters

stream Stream

El corrent.

options NotebookSaveOptions

Especifica les opcions de com s’emmagatzema el document.

Exceptions

IncorrectDocumentStructureException

L’estructura del document viola la especificació.

UnsupportedSaveFormatException

El format de salvament sol·licitat no es dóna suport.

 Català