Class Notebook
Der Name: Aspose.Note Zusammensetzung: Aspose.Note.dll (25.4.0)
Es handelt sich um ein Aspose.Note Notebook.
public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable
Inheritance
Implements
INotebookChildNode
,
IEnumerable
Vererbte Mitglieder
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Sie zeigen, wie man ein Notebook speichert.
// 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);
Zeigt, wie man das Notebook in PDF-Format speichert.
// 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);
Zeigt, wie man das Notebook als Bild speichert.
// 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);
Zeigt, wie man alle Texte aus einem Notebook erhält.
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>
Zeigt, wie man ein flattenter Notebook in PDF-Format speichert.
// 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
});
Zeigt, wie man durch Dokumente eines Notebooks iteriert, die sie leicht laden.
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>
Zeigt, wie man einen neuen Abschnitt zu einem Notebook hinzufügt.
// 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);
Zeigt, wie man das Notebook aus einem Stream laden kann.
// 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");
Zeigt, wie man ein verschlüsseltes Notebook macht.
// 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" });
Zeigt, wie man das Notebook als Bild mit angegebenen Optionen speichert.
// 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);
Zeigt, wie man das flattente Notebook als Bild speichert.
// 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);
Zeigt, wie man einen Abschnitt aus einem Notebook entfernen kann.
// 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>
Zeigt, wie man durch vorgeladenen Dokumente eines Notebooks iteriert.
// 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>
Zeigt, wie man durch den Inhalt eines Notebooks geht.
// 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()
Initialisiert eine neue Instanz der Aspose.Note. Notebook Klasse.
public Notebook()
Notebook(String)
Initialisiert eine neue Instanz der Aspose.Note. Notebook Klasse.Öffnen Sie einen vorhandenen OneNote-Notes aus einem Datei.
public Notebook(string filePath)
Parameters
filePath
string
Der Dateiweg.
Notebook(String, NotebookLoadOptions)
Initialisiert eine neue Instanz der Aspose.Note. Notebook Klasse.Öffnen Sie eine vorhandene OneNote-Nota aus einem Datei. Erlaubt es, zusätzliche Optionen wie eine Kinderladestrategie („lazy“/instant) anzuzeigen.
public Notebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
Der Dateiweg.
loadOptions
NotebookLoadOptions
Die Lastoptionen.
Notebook(Stream)
Initialisiert eine neue Instanz der Aspose.Note. Notebook Klasse.Öffnen Sie einen vorhandenen OneNote-Notbuch aus einem Stream.
public Notebook(Stream stream)
Parameters
stream
Stream
Der Strom.
Notebook(Stream, NotebookLoadOptions)
Initialisiert eine neue Instanz der Aspose.Note. Notebook Klasse.Öffnen Sie eine vorhandene OneNote-Nota aus einem Stream. Erlaubt, zusätzliche Ladungsoptionen zu angeben.
public Notebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
Der Strom.
loadOptions
NotebookLoadOptions
Die Lastoptionen.
Properties
Color
Gibt oder legt die Farbe fest.
public Color Color { get; set; }
Eigentumswert
Count
Erhält die Anzahl der Elemente, die im Aspose.Note.Buch enthalten sind.
public int Count { get; }
Eigentumswert
DisplayName
Erhalten oder setzen Sie den Display-Namen.
public string DisplayName { get; set; }
Eigentumswert
Examples
Zeigt, wie man einen Abschnitt aus einem Notebook entfernen kann.
// 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
Erhalten Sie das Dateiformat (OneNote 2010, OneNota Online).
public FileFormat FileFormat { get; }
Eigentumswert
Guid
Er bekommt das weltweit einzigartige ID des Objekts.
public Guid Guid { get; }
Eigentumswert
IsHistoryEnabled
Er bekommt oder setzt einen Wert, der angibt, ob die Geschichte aktiviert ist.
public bool IsHistoryEnabled { get; set; }
Eigentumswert
Diese[Int]
Er bekommt das Notebook-Kind-Node durch den gegebenen Index.
public INotebookChildNode this[int index] { get; }
Eigentumswert
Methods
AppendChild(EinträgeChildNode)
Fügen Sie die Node am Ende der Liste hinzu.
public INotebookChildNode AppendChild(INotebookChildNode newChild)
Parameters
newChild
INotebookChildNode
Die Node zu hinzufügen.
Returns
Die Node hinzugefügt.
GetChildNodes()
Erhalten Sie alle Knoten des Kindes nach Node-Typ.
public IList<t1> GetChildNodes<t1>() where T1 : Node
Returns
Eine Liste der Kinderknoten.
Arten von Parametern
T1
Die Art der Elemente in der zurückgegebenen Liste.
GetEnumerator()
Wiederherstellt eine Liste, die durch die Kinderknoten des Aspose.Note.Buchs iteriert.
public IEnumerator<inotebookchildnode> GetEnumerator()
Returns
IEnumerator &undlt; INotebookChildNode >
Ein System.Kollektionen.IEnumerator
LoadChildDocument(String)
Ein Kinderdokument node hinzufügen.Öffnen Sie ein bestehendes OneNote-Dokument aus einem Datei.
public void LoadChildDocument(string filePath)
Parameters
filePath
string
Der Dateiweg.
Examples
Zeigt, wie man das Notebook aus einem Stream laden kann.
// 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)
Ein Kinderdokument node hinzufügen.Öffnet ein bestehendes OneNote-Dokument aus einem Datei. Erlaubt, zusätzliche Ladungsoptionen zu angeben.
public void LoadChildDocument(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Der Dateiweg.
loadOptions
LoadOptions
Die Lastoptionen.
LoadChildDocument(Stream)
Ein Kinderdokument node hinzufügen.Öffnen Sie ein bestehendes OneNote-Dokument aus einem Stream.
public void LoadChildDocument(Stream stream)
Parameters
stream
Stream
Der Strom.
Examples
Zeigt, wie man das Notebook aus einem Stream laden kann.
// 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(Stream und LoadOptions)
Ein Kinderdokument node hinzufügen.Öffnet ein bestehendes OneNote-Dokument aus einem Stream. Erlaubt, zusätzliche Ladungsoptionen zu angeben.
public void LoadChildDocument(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
Der Strom.
loadOptions
LoadOptions
Die Lastoptionen.
LoadChildNotebook(String)
Hinzufügen eines Kindes Notebook Node.Öffnen Sie einen vorhandenen OneNote-Notes aus einem Datei.
public void LoadChildNotebook(string filePath)
Parameters
filePath
string
Der Dateiweg.
LoadChildNotebook(String, NotebookLoadOptions)
Hinzufügen eines Kindes Notebook Node.Öffnen Sie eine vorhandene OneNote-Nota aus einem Datei. Erlaubt, zusätzliche Ladungsoptionen zu angeben.
public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
Der Dateiweg.
loadOptions
NotebookLoadOptions
Die Lastoptionen.
LoadChildNotebook(Stream)
Hinzufügen eines Kindes Notebook Node.Öffnen Sie einen vorhandenen OneNote-Notbuch aus einem Stream.
public void LoadChildNotebook(Stream stream)
Parameters
stream
Stream
Der Strom.
LoadChildNotebook(Stream, NotebookLoadOptions)
Hinzufügen eines Kindes Notebook Node.Öffnen Sie eine vorhandene OneNote-Nota aus einem Stream. Erlaubt, zusätzliche Ladungsoptionen zu angeben.
public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
Der Strom.
loadOptions
NotebookLoadOptions
Die Lastoptionen.
RemoveChild(EinträgeChildNode)
Entfernen Sie das Kind Node.
public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
Parameters
oldChild
INotebookChildNode
Die Node zu entfernen.
Returns
Die entfernte Node.
Examples
Zeigt, wie man alle Abschnitte aus einem Notebook zugreifen kann.
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>
Zeigt, wie man einen Abschnitt aus einem Notebook entfernen kann.
// 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>
Sie zeigen, wie man ein Notebook speichert.
// 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)
Speichern Sie das OneNote-Dokument in eine Datei.
public void Save(string fileName)
Parameters
fileName
string
Wenn eine Datei mit dem angegebenen vollständigen Namen bereits vorhanden ist, wird die bestehende Dateie übergeschrieben.
Exceptions
IncorrectDocumentStructureException
Die Dokumentstruktur verletzt die Spezifikation.
UnsupportedSaveFormatException
Ersuchtes Speicherformat wird nicht unterstützt.
Save(Stream)
Speichern Sie das OneNote-Dokument in einen Strom.
public void Save(Stream stream)
Parameters
stream
Stream
Der Strom.
Exceptions
IncorrectDocumentStructureException
Die Dokumentstruktur verletzt die Spezifikation.
UnsupportedSaveFormatException
Ersuchtes Speicherformat wird nicht unterstützt.
Save(String und SaveFormat)
Speichert das OneNote-Dokument auf eine Datei im angegebenen Format.
public void Save(string fileName, SaveFormat format)
Parameters
fileName
string
Wenn eine Datei mit dem angegebenen vollständigen Namen bereits vorhanden ist, wird die bestehende Dateie übergeschrieben.
format
SaveFormat
Das Format, in dem Sie das Dokument speichern können.
Exceptions
IncorrectDocumentStructureException
Die Dokumentstruktur verletzt die Spezifikation.
UnsupportedSaveFormatException
Ersuchtes Speicherformat wird nicht unterstützt.
Save(Stream und SaveFormat)
Speichert das OneNote-Dokument in einem Stream im angegebenen Format.
public void Save(Stream stream, SaveFormat format)
Parameters
stream
Stream
Der Strom.
format
SaveFormat
Das Format, in dem Sie das Dokument speichern können.
Exceptions
IncorrectDocumentStructureException
Die Dokumentstruktur verletzt die Spezifikation.
UnsupportedSaveFormatException
Ersuchtes Speicherformat wird nicht unterstützt.
Save(String, NotebookSaveOptions)
Speichern Sie das OneNote-Dokument in eine Datei mit den angegebenen Speicheroptionen.
public void Save(string fileName, NotebookSaveOptions options)
Parameters
fileName
string
Wenn eine Datei mit dem angegebenen vollständigen Namen bereits vorhanden ist, wird die bestehende Dateie übergeschrieben.
options
NotebookSaveOptions
Angeben Sie die Optionen, wie das Dokument in der Datei gespeichert wird.
Exceptions
IncorrectDocumentStructureException
Die Dokumentstruktur verletzt die Spezifikation.
UnsupportedSaveFormatException
Ersuchtes Speicherformat wird nicht unterstützt.
Save(Stream, NotebookSaveOptions)
Speichern Sie das OneNote-Dokument in einen Strom, indem Sie die angegebenen Speicheroptionen verwenden.
public void Save(Stream stream, NotebookSaveOptions options)
Parameters
stream
Stream
Der Strom.
options
NotebookSaveOptions
Angeben Sie die Optionen, wie das Dokument gespeichert wird.
Exceptions
IncorrectDocumentStructureException
Die Dokumentstruktur verletzt die Spezifikation.
UnsupportedSaveFormatException
Ersuchtes Speicherformat wird nicht unterstützt.