Class Notebook

Class Notebook

Il nome: Aspose.Note Assemblea: Aspose.Note.dll (25.4.0)

Si tratta di un notebook Aspose.Note.

public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable
{
    public void Add(inotebookchildnode childNode)
    {
        _children.Add(childNode);
    }
    public void Remove(inotebookchildnode childNode)
    {
        _children.Remove(childNode);
    }
    public bool Contains(inotebookchildnode childNode)
    {
        return _children.Contains(childNode);
    }
    IEnumerator IEnumerable.GetEnumerator()
    {
        foreach (var child in _children)
            yield return child;
    }
    IEnumerator<inotebookchildnode> IEnumerable<inotebookchildnode>.GetEnumerator()
    {
        foreach (var child in _children)
            yield return child;
    }
    private List<inotebookchildnode> _children = new List<inotebookchildnode>();
}

Inheritance

object Notebook

Implements

INotebookChildNode , IEnumerable , IEnumerable

I membri ereditari

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

Examples

Scopri come salvare il notebook.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook();
   dataDir += "test_out.onetoc2";
   notebook.Save(dataDir);

Mostra come salvare il notebook in formato pdf.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
   dataDir += "ConvertToPDF_out.pdf";
   notebook.Save(dataDir);

Mostra come salvare il notebook come immagine.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
   dataDir += "ConvertToImage_out.png";
   notebook.Save(dataDir);

Mostra come ottenere tutto il testo da 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);
   }

Mostra come salvare un notebook flattato in formato pdf.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
   dataDir += "ConvertToPDFAsFlattened_out.pdf";
   notebook.Save(
       dataDir,
       new NotebookPdfSaveOptions
       {
           Flatten = true
       });

Mostra come iterare attraverso i documenti di un notebook che li carica lisciamente.

string inputFile = "Notizbuch öffnen.onetoc2";
   string dataDir = RunExamples.GetDataDir_NoteBook();
   Notebook notebook = new Notebook(dataDir + inputFile);
   foreach (var notebookChildNode in notebook.OfType<Document>())
   {
   }

Mostra come aggiungere una nuova sezione a un notebook.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
   notebook.AppendChild(new Document(dataDir + "Neuer Abschnitt 1.one"));
   dataDir += @"\AddChildNode_out.onetoc2";
   notebook.Save(dataDir);

Mostra come caricare il notebook da un flusso.

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 come creare un notebook crittografato.

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 come salvare il notebook come immagine con le opzioni specificate.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch �ffnen.onetoc2");
   var notebookSaveOptions = new NotebookImageSaveOptions { SaveFormat = SaveFormat.Png };
   var documentSaveOptions = notebookSaveOptions.DocumentSaveOptions;
   documentSaveOptions.Resolution = 400;
   dataDir += "ConvertToImageWithOptions_out.png";
   notebook.Save(dataDir, notebookSaveOptions);

Mostra come salvare il notebook flattato come immagine.

string dataDir = RunExamples.GetDataDir_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 += "ConvertToImageAsFlattenedNotebook_out.png";
   notebook.Save(dataDir, notebookSaveOptions);

Mostra come rimuovere una sezione da un notebook.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "test.onetoc2");
   foreach (var child in new List<inotebookchildnode>(notebook))
   {
       if (child.DisplayName == "Remove Me")
       {
           notebook.RemoveChild(child);
       }
   }
   dataDir = dataDir + "RemoveChildNode_out.onetoc2";
   notebook.Save(dataDir);

Mostra come iterare attraverso i documenti precaricati di un notebook.

NotebookLoadOptions loadOptions = new NotebookLoadOptions { InstantLoading = true };
   string inputFile = "Notizbuch öffnen.onetoc2";
   string dataDir = RunExamples.GetDataDir_NoteBook();
   Notebook notebook = new Notebook(dataDir + inputFile, loadOptions);
   foreach (INotebookChildNode notebookChildNode in notebook.OfType<Document>())
   {
   }

Mostra come passare attraverso il contenuto di un notebook.

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)
           {
           }
           else if (notebookChildNode is Notebook)
           {
           }
       }
   }
   catch (Exception ex)
   {
       Console.WriteLine(ex.Message);
   }

Constructors

Il libro ( )

Inizia una nuova instanza della classe Aspose.Note.Notebook.

public Notebook()
   {
   }

Il libro (string )

Inizia una nuova instanza della classe Aspose.Note.Notebook.Apri un notebook OneNote esistente da un file.

public Notebook(string filePath)
   {
   }

Parameters

filePath string

Il percorso del file.

Notebook (string, opzioni di caricamento di notebook)

Inizia una nuova instanza della classe Aspose.Note.Notebook.Apri un notebook OneNote esistente da un file. consente di specificare ulteriori opzioni come una strategia di caricamento per bambini (“lazy” / instant).

public Notebook(string filePath, NotebookLoadOptions loadOptions)
   {
   }

Parameters

filePath string

Il percorso del file.

loadOptions NotebookLoadOptions

Le opzioni di carico.

Il libro (Stream)

Inizia una nuova instanza della classe Aspose.Note.Notebook.Apri un notebook OneNote esistente da un flusso.

public class Notebook
   {
      public Notebook(Stream stream)
      {
      }
   }

Parameters

stream Stream

Il flusso .

Notebook (Stream, Opzioni di caricamento dei Notebooks)

Inizia una nuova instanza della classe Aspose.Note.Notebook.Apri un notebook OneNote esistente da un flusso. consente di specificare ulteriori opzioni di caricamento.

public Notebook(Stream stream, NotebookLoadOptions loadOptions)
   {
   }

Parameters

stream Stream

Il flusso .

loadOptions NotebookLoadOptions

Le opzioni di carico.

Properties

Color

Riceve o mette il colore.

public Color Color
   {
      get
      {
         return this.Color;
      }
      set
      {
         this.Color = value;
      }
   }

Valore di proprietà

Color

Count

Riceve il numero di elementi contenuti nel Aspose.Note.Notebook.

public int Count
   {
      get;
   }

Valore di proprietà

int

DisplayName

Riceve o impone il nome della visualizzazione.

public string DisplayName
   {
      get;
      set;
   }

Valore di proprietà

string

Examples

Mostra come rimuovere una sezione da un notebook.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "test.onetoc2");
   foreach (var child in new List<InotebookChildNode>(notebook))
   {
      if (child.DisplayName == "Remove Me")
      {
         notebook.RemoveChild(child);
      }
   }
   dataDir = dataDir + "RemoveChildNode_out.onetoc2";
   notebook.Save(dataDir);
Notes:

FileFormat

Riceve il formato di file (OneNote 2010, OneNota Online).

public FileFormat FileFormat
   {
      get;
   }

Valore di proprietà

FileFormat

Guid

Riceve l’ID unico globale dell’oggetto.

public Guid Guid
   {
      get;
   }

Valore di proprietà

Guid

IsHistoryEnabled

Riceve o impone un valore che indica se la storia è abilitata.

public bool IsHistoryEnabled
   {
      get;
      set;
   }

Valore di proprietà

bool

Questo[di int)

Riceve il nodo bambino del notebook per l’indice dato.

public INotebookChildNode this[int index]
   {
      get;
   }

Valore di proprietà

INotebookChildNode

Methods

AppendChild (InotebookNode)

Aggiungi il nodo alla fine della lista.

public INotebookChildNode AppendChild(INotebookChildNode newChild)
   {
      return _notebook.AppendChild(newChild);
   }

Parameters

newChild INotebookChildNode

Il nodo da aggiungere.

Returns

INotebookChildNode

Il nodo aggiunto.

GetChildNodes()

Ottieni tutti i nodi del bambino secondo il tipo di nodi.

public IList<T1> GetChildNodes<T1>() where T1 : Node
    {
    }

Returns

IList

Un elenco dei nodi infantili.

Tipo di parametri

T1

Il tipo di elementi nella lista restituita.

Scrivi una recensione ()

Ritorna un enumeratore che iterato attraverso i nodi infantili del Aspose.Note.Notebook.

public IEnumerator<notebookchildnode> GetEnumerator()
   {
   }

Returns

IEnumerator di < INotebookChildNode >

Un sistema di raccolte.IEnumerator.

LoadChildDocument (string)

Aggiungi un nodo di documento per bambini.Apri un documento OneNote esistente da un file.

public void LoadChildDocument(string filePath)
   {
   }

Parameters

filePath string

Il percorso del file.

Examples

Mostra come caricare il notebook da un flusso.

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, opzioni di carico)

Aggiungi un nodo di documento per bambini.Apri un documento OneNote esistente da un file. consente di specificare ulteriori opzioni di caricamento.

public void LoadChildDocument(string filePath, Aspose.Words.LoadOptions loadOptions)
   {
   }

Parameters

filePath string

Il percorso del file.

loadOptions LoadOptions

Le opzioni di carico.

LoadChildDocument (strumento)

Aggiungi un nodo di documento per bambini.Apri un documento OneNote esistente da un flusso.

public void LoadChildDocument(Stream stream)
   {
   }

Parameters

stream Stream

Il flusso .

Examples

Mostra come caricare il notebook da un flusso.

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 (Stream, Opzioni di ricarica)

Aggiungi un nodo di documento per bambini.Apri un documento OneNote esistente da un flusso. consente di specificare ulteriori opzioni di carico.

public void LoadChildDocument(Stream stream, LoadOptions loadOptions)
   {
   }

Parameters

stream Stream

Il flusso .

loadOptions LoadOptions

Le opzioni di carico.

Scrivi una recensione per LoadChildNotebook(string)

Aggiungi un nodo di notebook per bambini.Apri un notebook OneNote esistente da un file.

public void LoadChildNotebook(string filePath)
   {
   }

Parameters

filePath string

Il percorso del file.

LoadChildNotebook(string, NotebookLoadOptions)

Aggiungi un nodo di notebook per bambini.Apri un notebook OneNote esistente da un file. consente di specificare ulteriori opzioni di caricamento.

public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
   {
   }

Parameters

filePath string

Il percorso del file.

loadOptions NotebookLoadOptions

Le opzioni di carico.

Scrivi una recensione per LoadChildNotebook (Stream)

Aggiungi un nodo di notebook per bambini.Apri un notebook OneNote esistente da un flusso.

public void LoadChildNotebook(Stream stream)
   {
   }

Parameters

stream Stream

Il flusso .

LoadChildNotebook(Stream, NotebookLoadOptions)

Aggiungi un nodo di notebook per bambini.Apri un notebook OneNote esistente da un flusso. consente di specificare ulteriori opzioni di carico.

public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
   {
   }

Parameters

stream Stream

Il flusso .

loadOptions NotebookLoadOptions

Le opzioni di carico.

Rimuovere (INotebookChildNode)

Rimuovere il nodo del bambino.

public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
   {
   }

Parameters

oldChild INotebookChildNode

Il nodo da rimuovere.

Returns

INotebookChildNode

Il nodo rimosso.

Examples

Mostra come accedere a tutte le sezioni da 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);
   }

Mostra come rimuovere una sezione da un notebook.

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "test.onetoc2");
   foreach (var child in new List<inotebookchildnode>(notebook))
   {
      if (child.DisplayName == "Remove Me")
      {
         notebook.RemoveChild(child);
      }
   }
   dataDir = dataDir + "RemoveChildNode_out.onetoc2";
   notebook.Save(dataDir);

Scopri come salvare un notebook.

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 + "NotLocked_out.one");
      var childDocument1 = notebook[1] as Document;
      childDocument1.Save(dataDir + "LockedPass1_out.one", new OneSaveOptions() { DocumentPassword = "pass" });
      var childDocument2 = notebook[2] as Document;
      childDocument2.Save(dataDir + "LockedPass2_out.one", new OneSaveOptions() { DocumentPassword = "pass2" });
   }

Salvataggio ( String )

Salva il documento OneNote in un file.

public void Save(string fileName)
   {
   }

Parameters

fileName string

Se un file con il nome completo specificato esiste già, il file esistente viene sopratto.

Exceptions

IncorrectDocumentStructureException

La struttura del documento viola le specifiche.

UnsupportedSaveFormatException

Il formato di salvataggio richiesto non è supportato.

Il salvataggio (Stream)

Salva il documento OneNote in un flusso.

public void Save(Stream stream)
   {
   }

Parameters

stream Stream

Il flusso .

Exceptions

IncorrectDocumentStructureException

La struttura del documento viola le specifiche.

UnsupportedSaveFormatException

Il formato di salvataggio richiesto non è supportato.

Salva (string e SaveFormat)

Salva il documento OneNote in un file nel formato specificato.

public void Save(string fileName, Aspose.Words.SaveFormat format)
   {
   }

Parameters

fileName string

Se un file con il nome completo specificato esiste già, il file esistente viene sopratto.

format SaveFormat

Il formato in cui salvare il documento.

Exceptions

IncorrectDocumentStructureException

La struttura del documento viola le specifiche.

UnsupportedSaveFormatException

Il formato di salvataggio richiesto non è supportato.

Salva (Stream e SaveFormat)

Salva il documento OneNote in un flusso nel formato specificato.

public void Save(Stream stream, SaveFormat format)
   {
   }

Parameters

stream Stream

Il flusso .

format SaveFormat

Il formato in cui salvare il documento.

Exceptions

IncorrectDocumentStructureException

La struttura del documento viola le specifiche.

UnsupportedSaveFormatException

Il formato di salvataggio richiesto non è supportato.

Salva (string, NotebookSaveOptions)

Salva il documento OneNote in un file utilizzando le opzioni di salvataggio specificate.

public void Save(string fileName, NotebookSaveOptions options)
   {
   }

Parameters

fileName string

Se un file con il nome completo specificato esiste già, il file esistente viene sopratto.

options NotebookSaveOptions

Specifica le opzioni su come il documento viene salvato nel file.

Exceptions

IncorrectDocumentStructureException

La struttura del documento viola le specifiche.

UnsupportedSaveFormatException

Il formato di salvataggio richiesto non è supportato.

Salva (Stream, NotebookSaveOptions)

Salva il documento OneNote in un flusso utilizzando le opzioni di salvataggio specificate.

public void Save(Stream stream, NotebookSaveOptions options)
   {
   }

Parameters

stream Stream

Il flusso .

options NotebookSaveOptions

Indica le opzioni su come viene salvato il documento.

Exceptions

IncorrectDocumentStructureException

La struttura del documento viola le specifiche.

UnsupportedSaveFormatException

Il formato di salvataggio richiesto non è supportato.

 Italiano