Class Notebook

Class Notebook

Nombre del espacio: Aspose.Note Asamblea: Aspose.Note.dll (25.4.0)

Representa un Aspose.Note portátil.

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

Inheritance

object Notebook

Implements

INotebookChildNode ,y, IEnumerable ,y, IEnumerable

Miembros heredados

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

Examples

Mostra cómo guardar un 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 cómo guardar un notebook en formato 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 cómo guardar un notebook como imagen.

// 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 cómo obtener todo el texto de 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 cómo guardar un notebook en formato 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 cómo iterar a través de los documentos de un notebook cargándolos lazamente.

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 cómo agregar una nueva sección 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 cómo cargar un notebook de un flujo.

// 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 cómo hacer un notebook cifrado.

// 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 cómo guardar un notebook como imagen con opciones especificadas.

// 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 cómo guardar un notebook en forma de imagen.

// 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 cómo eliminar una sección de 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 cómo iterar a través de documentos precargados de 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 cómo pasar por el contenido de 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()

Inicia una nueva instancia de la clase Aspose.Note.Notebook.

public Notebook()

Notebook(El string)

Inicia una nueva instancia de la clase Aspose.Note.Notebook.Abrir un notebook de OneNote existente desde un archivo.

public Notebook(string filePath)

Parameters

filePath string

El camino del archivo.

Notebook(Título: NotebookLoadOptions)

Inicia una nueva instancia de la clase Aspose.Note.Notebook.Abre un notebook OneNote existente desde un archivo. permite especificar opciones adicionales como una estrategia de carga infantil (“lazy” / instant).

public Notebook(string filePath, NotebookLoadOptions loadOptions)

Parameters

filePath string

El camino del archivo.

loadOptions NotebookLoadOptions

Las opciones de carga.

Notebook(Stream)

Inicia una nueva instancia de la clase Aspose.Note.Notebook.Abre un notebook OneNote existente desde un flujo.

public Notebook(Stream stream)

Parameters

stream Stream

El flujo.

Notebook(Título: NotebookLoadOptions)

Inicia una nueva instancia de la clase Aspose.Note.Notebook.Abre un notebook OneNote existente desde un flujo. permite especificar opciones de carga adicionales.

public Notebook(Stream stream, NotebookLoadOptions loadOptions)

Parameters

stream Stream

El flujo.

loadOptions NotebookLoadOptions

Las opciones de carga.

Properties

Color

Obtenga o coloca el color.

public Color Color { get; set; }

Valor de la propiedad

Color

Count

Obtenga el número de elementos contenidos en el Aspose.Note.Notebook.

public int Count { get; }

Valor de la propiedad

int

DisplayName

Obtenga o establece el nombre de la pantalla.

public string DisplayName { get; set; }

Valor de la propiedad

string

Examples

Mostra cómo eliminar una sección de 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

Obtener el formato de archivo (OneNote 2010, OneNota Online).

public FileFormat FileFormat { get; }

Valor de la propiedad

FileFormat

Guid

Obtenga la identidad única del objeto.

public Guid Guid { get; }

Valor de la propiedad

Guid

IsHistoryEnabled

Obtenga o establece un valor que indique si la historia está activada.

public bool IsHistoryEnabled { get; set; }

Valor de la propiedad

bool

Este[Int]

Obtendrá el nodo de bebé por el índice dado.

public INotebookChildNode this[int index] { get; }

Valor de la propiedad

INotebookChildNode

Methods

AppendChild(Título: InotebookChildNode)

Añade el nodo al final de la lista.

public INotebookChildNode AppendChild(INotebookChildNode newChild)

Parameters

newChild INotebookChildNode

El nodo para añadir.

Returns

INotebookChildNode

El nodo añadido.

Título: T1>()

Obtenga todos los nodos del niño por el tipo de nodo.

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

Returns

IList

Una lista de nódulos infantiles.

Tipos de Parámetros

T1

El tipo de elementos en la lista devuelta.

GetEnumerator()

Retorna un enumerador que itera a través de los nódulos infantiles del Aspose.Note.Notebook.

public IEnumerator<inotebookchildnode> GetEnumerator()

Returns

IEnumerator &ylt; INotebookChildNode >

Un sistema.Colecciones.IEnumerador

LoadChildDocument(El string)

Añade un nodo de documento infantil.Abrir un documento de OneNote existente desde un archivo.

public void LoadChildDocument(string filePath)

Parameters

filePath string

El camino del archivo.

Examples

Mostra cómo cargar un notebook de un flujo.

// 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(Título: LoadOptions)

Añade un nodo de documento infantil.Abre un documento de OneNote existente desde un archivo. permite especificar opciones de carga adicionales.

public void LoadChildDocument(string filePath, LoadOptions loadOptions)

Parameters

filePath string

El camino del archivo.

loadOptions LoadOptions

Las opciones de carga.

LoadChildDocument(Stream)

Añade un nodo de documento infantil.Abrir un documento de OneNote existente desde un flujo.

public void LoadChildDocument(Stream stream)

Parameters

stream Stream

El flujo.

Examples

Mostra cómo cargar un notebook de un flujo.

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

Añade un nodo de documento infantil.Abre un documento de OneNote existente desde un flujo. permite especificar opciones de carga adicionales.

public void LoadChildDocument(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

El flujo.

loadOptions LoadOptions

Las opciones de carga.

LoadChildNotebook(El string)

Adiciona un nodo de notas infantiles.Abrir un notebook de OneNote existente desde un archivo.

public void LoadChildNotebook(string filePath)

Parameters

filePath string

El camino del archivo.

LoadChildNotebook(Título: NotebookLoadOptions)

Adiciona un nodo de notas infantiles.Abre un notebook OneNote existente desde un archivo. permite especificar opciones de carga adicionales.

public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)

Parameters

filePath string

El camino del archivo.

loadOptions NotebookLoadOptions

Las opciones de carga.

LoadChildNotebook(Stream)

Adiciona un nodo de notas infantiles.Abre un notebook OneNote existente desde un flujo.

public void LoadChildNotebook(Stream stream)

Parameters

stream Stream

El flujo.

LoadChildNotebook(Título: NotebookLoadOptions)

Adiciona un nodo de notas infantiles.Abre un notebook OneNote existente desde un flujo. permite especificar opciones de carga adicionales.

public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)

Parameters

stream Stream

El flujo.

loadOptions NotebookLoadOptions

Las opciones de carga.

RemoveChild(Título: InotebookChildNode)

Elimina el nodo del niño.

public INotebookChildNode RemoveChild(INotebookChildNode oldChild)

Parameters

oldChild INotebookChildNode

El nodo para eliminar.

Returns

INotebookChildNode

El nodo eliminado.

Examples

Mostra cómo acceder a todas las secciones de 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 cómo eliminar una sección de 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 cómo guardar 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(El string)

Salva el documento OneNote a un archivo.

public void Save(string fileName)

Parameters

fileName string

Si un archivo con el nombre completo especificado ya existe, el fichero existente se sobreescrita.

Exceptions

IncorrectDocumentStructureException

La estructura del documento viola la especificación.

UnsupportedSaveFormatException

El formato de almacenamiento solicitado no se apoya.

Save(Stream)

Salva el documento OneNote a un flujo.

public void Save(Stream stream)

Parameters

stream Stream

El flujo.

Exceptions

IncorrectDocumentStructureException

La estructura del documento viola la especificación.

UnsupportedSaveFormatException

El formato de almacenamiento solicitado no se apoya.

Save(Título: SaveFormat)

Salva el documento OneNote a un archivo en el formato especificado.

public void Save(string fileName, SaveFormat format)

Parameters

fileName string

Si un archivo con el nombre completo especificado ya existe, el fichero existente se sobreescrita.

format SaveFormat

El formato en el que guardar el documento.

Exceptions

IncorrectDocumentStructureException

La estructura del documento viola la especificación.

UnsupportedSaveFormatException

El formato de almacenamiento solicitado no se apoya.

Save(Cortesía, SaveFormat)

Salva el documento OneNote a un flujo en el formato especificado.

public void Save(Stream stream, SaveFormat format)

Parameters

stream Stream

El flujo.

format SaveFormat

El formato en el que guardar el documento.

Exceptions

IncorrectDocumentStructureException

La estructura del documento viola la especificación.

UnsupportedSaveFormatException

El formato de almacenamiento solicitado no se apoya.

Save(Título: NotebookSaveOptions)

Salva el documento de OneNote a un archivo utilizando las opciones de salvo especificadas.

public void Save(string fileName, NotebookSaveOptions options)

Parameters

fileName string

Si un archivo con el nombre completo especificado ya existe, el fichero existente se sobreescrita.

options NotebookSaveOptions

Especifica las opciones de cómo se salva el documento en el archivo.

Exceptions

IncorrectDocumentStructureException

La estructura del documento viola la especificación.

UnsupportedSaveFormatException

El formato de almacenamiento solicitado no se apoya.

Save(Título: NotebookSaveOptions)

Salva el documento de OneNote a un flujo utilizando las opciones de salvo especificadas.

public void Save(Stream stream, NotebookSaveOptions options)

Parameters

stream Stream

El flujo.

options NotebookSaveOptions

Especifica las opciones de cómo se salva el documento.

Exceptions

IncorrectDocumentStructureException

La estructura del documento viola la especificación.

UnsupportedSaveFormatException

El formato de almacenamiento solicitado no se apoya.

 Español