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
Inheritance
Implements
INotebookChildNode
,
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.
// 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 come salvare il notebook in 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 come salvare il notebook come immagine.
// 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 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);
}</richtext></richtext>
Mostra come salvare un notebook flattato in 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 come iterare attraverso i documenti di un notebook che li carica lisciamente.
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 come aggiungere una nuova sezione 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 come caricare il notebook da un flusso.
// 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 come creare un notebook crittografato.
// 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 come salvare il notebook come immagine con le opzioni specificate.
// 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 come salvare il notebook flattato come immagine.
// 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 come rimuovere una sezione da 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 come iterare attraverso i documenti precaricati di 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 come passare attraverso il contenuto di 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()
Inizia una nuova instanza della classe Aspose.Note.Notebook.
public Notebook()
Notebook(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, NotebookLoadOptions)
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.
Notebook(Stream)
Inizia una nuova instanza della classe Aspose.Note.Notebook.Apri un notebook OneNote esistente da un flusso.
public Notebook(Stream stream)
Parameters
stream
Stream
Il flusso .
Notebook(Trattamento, NotebookLoadOptions)
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; set; }
Valore di proprietà
Count
Riceve il numero di elementi contenuti nel Aspose.Note.Notebook.
public int Count { get; }
Valore di proprietà
DisplayName
Riceve o impone il nome della visualizzazione.
public string DisplayName { get; set; }
Valore di proprietà
Examples
Mostra come rimuovere una sezione da 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
Riceve il formato di file (OneNote 2010, OneNota Online).
public FileFormat FileFormat { get; }
Valore di proprietà
Guid
Riceve l’ID unico globale dell’oggetto.
public Guid Guid { get; }
Valore di proprietà
IsHistoryEnabled
Riceve o impone un valore che indica se la storia è abilitata.
public bool IsHistoryEnabled { get; set; }
Valore di proprietà
Questo[int]
Riceve il nodo bambino del notebook per l’indice dato.
public INotebookChildNode this[int index] { get; }
Valore di proprietà
Methods
AppendChild(IntegrazioneChildNode)
Aggiungi il nodo alla fine della lista.
public INotebookChildNode AppendChild(INotebookChildNode newChild)
Parameters
newChild
INotebookChildNode
Il nodo da aggiungere.
Returns
Il nodo aggiunto.
Riflessioni > T1>()
Ottieni tutti i nodi del bambino secondo il tipo di nodi.
public IList<t1> GetChildNodes<t1>() where T1 : Node
Returns
Un elenco dei nodi infantili.
Tipo di parametri
T1
Il tipo di elementi nella lista restituita.
GetEnumerator()
Ritorna un enumeratore che iterato attraverso i nodi infantili del Aspose.Note.Notebook.
public IEnumerator<inotebookchildnode> 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.
// 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, LoadOptions)
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, LoadOptions loadOptions)
Parameters
filePath
string
Il percorso del file.
loadOptions
LoadOptions
Le opzioni di carico.
LoadChildDocument(Stream)
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.
// 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(LoadOptions e LoadOptions)
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.
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.
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(Trattamento, 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.
RemoveChild(IntegrazioneChildNode)
Rimuovere il nodo del bambino.
public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
Parameters
oldChild
INotebookChildNode
Il nodo da rimuovere.
Returns
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);
}</document></document>
Mostra come rimuovere una sezione da 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>
Scopri come salvare 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(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.
Save(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.
Save(Riflessioni, SaveFormat)
Salva il documento OneNote in un file nel formato specificato.
public void Save(string fileName, 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.
Save(Sviluppo, 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.
Save(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.
Save(Trattamento, 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.