Class Notebook
Numele spaţiului: Aspose.Note Asamblare: Aspose.Note.dll (25.4.0)
Prezintă un notebook Aspose.Note.
public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable
Inheritance
Implements
INotebookChildNode
,
IEnumerable
Membrii moștenitori
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Află cum să salvați notebook-ul.
// 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);
Află cum să salvați notebook-ul în 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);
Afișează cum să salvați notebook-ul ca imagine.
// 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);
arată cum să obțineți întregul text dintr-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>
Afișează cum să salvați notebook-ul în 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
});
arată cum să itereze prin documente dintr-un notebook încărcându-le cu ușurință.
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>
Află cum să adăugați o secțiune nouă la 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);
arată cum să încărcați notebook-ul dintr-un flux.
// 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");
Află cum să faci un notebook criptat.
// 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" });
arată cum să salvați notebook-ul ca imagine cu opțiuni 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);
Afișează cum să salvați notebook-ul plăcut ca imagine.
// 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);
arată cum să eliminați o secțiune dintr-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>
Afișează cum să iterați prin documentele încărcate dintr-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>
Află cum să treci prin conținutul unui 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()
Inițializează o nouă instanță a clasei Aspose.Note.Notebook.
public Notebook()
Notebook(Strângere)
Inițializează o nouă instanță a clasei Aspose.Note.Notebook.Deschide un notebook OneNote existent dintr-un fișier.
public Notebook(string filePath)
Parameters
filePath
string
Calea de fișier.
Notebook(Cuvânt cheie, NotebookLoadOptions)
Inițializează o nouă instanță a clasei Aspose.Note.Notebook.Deschide un notebook OneNote existent dintr-un fișier. permite specificarea opțiunilor suplimentare, cum ar fi o strategie de încărcare a copiilor (“lazy” / instant).
public Notebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
Calea de fișier.
loadOptions
NotebookLoadOptions
Opţiunile de încărcare.
Notebook(Stream)
Inițializează o nouă instanță a clasei Aspose.Note.Notebook.Deschideți un notebook OneNote existent dintr-un flux.
public Notebook(Stream stream)
Parameters
stream
Stream
şi fluxul .
Notebook(Articole cu eticheta, NotebookLoadOptions)
Inițializează o nouă instanță a clasei Aspose.Note.Notebook.Deschide un notebook OneNote existent dintr-un flux. Permite să specificați opțiuni suplimentare de încărcare.
public Notebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
şi fluxul .
loadOptions
NotebookLoadOptions
Opţiunile de încărcare.
Properties
Color
Obține sau stabilește culoarea.
public Color Color { get; set; }
Valoarea proprietății
Count
Obține numărul de elemente conținute în Aspose.Note.Notebook.
public int Count { get; }
Valoarea proprietății
DisplayName
Obțineți sau introduceți numele de afișare.
public string DisplayName { get; set; }
Valoarea proprietății
Examples
arată cum să eliminați o secțiune dintr-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
Obțineți format de fișier (OneNote 2010, OneNota Online).
public FileFormat FileFormat { get; }
Valoarea proprietății
Guid
Obține ID-ul unic la nivel mondial al obiectului.
public Guid Guid { get; }
Valoarea proprietății
IsHistoryEnabled
Obține sau stabilește o valoare care indică dacă istoria este activată.
public bool IsHistoryEnabled { get; set; }
Valoarea proprietății
Această[int]
Obține nodul copilului notebook prin indexul dat.
public INotebookChildNode this[int index] { get; }
Valoarea proprietății
Methods
AppendChild(EtichetăChildNode)
Adăugați nodul la sfârșitul listei.
public INotebookChildNode AppendChild(INotebookChildNode newChild)
Parameters
newChild
INotebookChildNode
Node pentru a adăuga.
Returns
cu nodul adăugat.
Cuvânt cheie()
Obțineți toate nodurile copilului după tipul nodului.
public IList<t1> GetChildNodes<t1>() where T1 : Node
Returns
O listă de noduri pentru copii.
Tipuri de parametri
T1
Tipul de elemente din lista returnată.
GetEnumerator()
Întoarce un enumerator care iterează prin nodurile pentru copii ale Aspose.Note.Notebook.
public IEnumerator<inotebookchildnode> GetEnumerator()
Returns
IEnumerator < INotebookChildNode >
Un sistem.Colecții.IEnumerator
LoadChildDocument(Strângere)
Adăugați un nod de document pentru copii.Deschide un document OneNote existent dintr-un fișier.
public void LoadChildDocument(string filePath)
Parameters
filePath
string
Calea de fișier.
Examples
arată cum să încărcați notebook-ul dintr-un flux.
// 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, Opțiuni de încărcare)
Adăugați un nod de document pentru copii.Deschide un document OneNote existent dintr-un fișier. permite specificarea opțiunilor suplimentare de încărcare.
public void LoadChildDocument(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Calea de fișier.
loadOptions
LoadOptions
Opţiunile de încărcare.
LoadChildDocument(Stream)
Adăugați un nod de document pentru copii.Deschide un document OneNote existent dintr-un flux.
public void LoadChildDocument(Stream stream)
Parameters
stream
Stream
şi fluxul .
Examples
arată cum să încărcați notebook-ul dintr-un flux.
// 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(Opțiuni, opțiuni de încărcare)
Adăugați un nod de document pentru copii.Deschide un document OneNote existent dintr-un flux. Permite să specificați opțiuni suplimentare de încărcare.
public void LoadChildDocument(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
şi fluxul .
loadOptions
LoadOptions
Opţiunile de încărcare.
LoadChildNotebook(Strângere)
Adăugați un nod de notebook pentru copii.Deschide un notebook OneNote existent dintr-un fișier.
public void LoadChildNotebook(string filePath)
Parameters
filePath
string
Calea de fișier.
LoadChildNotebook(Cuvânt cheie, NotebookLoadOptions)
Adăugați un nod de notebook pentru copii.Deschide un notebook OneNote existent dintr-un fișier. permite specificarea opțiunilor suplimentare de încărcare.
public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
Calea de fișier.
loadOptions
NotebookLoadOptions
Opţiunile de încărcare.
LoadChildNotebook(Stream)
Adăugați un nod de notebook pentru copii.Deschideți un notebook OneNote existent dintr-un flux.
public void LoadChildNotebook(Stream stream)
Parameters
stream
Stream
şi fluxul .
LoadChildNotebook(Articole cu eticheta, NotebookLoadOptions)
Adăugați un nod de notebook pentru copii.Deschide un notebook OneNote existent dintr-un flux. Permite să specificați opțiuni suplimentare de încărcare.
public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
şi fluxul .
loadOptions
NotebookLoadOptions
Opţiunile de încărcare.
RemoveChild(EtichetăChildNode)
Îndepărtează nodul copilului.
public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
Parameters
oldChild
INotebookChildNode
Node pentru a elimina.
Returns
cu nodul îndepărtat.
Examples
arată cum să accesezi toate secțiunile dintr-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>
arată cum să eliminați o secțiune dintr-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>
Afișează cum să salvați 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(Strângere)
Salvează documentul OneNote într-un fișier.
public void Save(string fileName)
Parameters
fileName
string
Dacă există deja un fișier cu numele complet specificat, fișa existentă este supraîncrisă.
Exceptions
IncorrectDocumentStructureException
Structura documentului încalcă specificația.
UnsupportedSaveFormatException
Formatul de salvare solicitat nu este susținut.
Save(Stream)
Salvează documentul OneNote într-un flux.
public void Save(Stream stream)
Parameters
stream
Stream
şi fluxul .
Exceptions
IncorrectDocumentStructureException
Structura documentului încalcă specificația.
UnsupportedSaveFormatException
Formatul de salvare solicitat nu este susținut.
Save(Cuvânt cheie, SaveFormat)
Salvează documentul OneNote într-un fișier în format specificat.
public void Save(string fileName, SaveFormat format)
Parameters
fileName
string
Dacă există deja un fișier cu numele complet specificat, fișa existentă este supraîncrisă.
format
SaveFormat
Formatul în care să salvați documentul.
Exceptions
IncorrectDocumentStructureException
Structura documentului încalcă specificația.
UnsupportedSaveFormatException
Formatul de salvare solicitat nu este susținut.
Save(Cuvânt cheie, SaveFormat)
Salvează documentul OneNote într-un flux în format specificat.
public void Save(Stream stream, SaveFormat format)
Parameters
stream
Stream
şi fluxul .
format
SaveFormat
Formatul în care să salvați documentul.
Exceptions
IncorrectDocumentStructureException
Structura documentului încalcă specificația.
UnsupportedSaveFormatException
Formatul de salvare solicitat nu este susținut.
Save(Cuvânt cheie, NotebookSaveOptions)
Salvează documentul OneNote într-un fișier folosind opțiunile de salvare specificate.
public void Save(string fileName, NotebookSaveOptions options)
Parameters
fileName
string
Dacă există deja un fișier cu numele complet specificat, fișa existentă este supraîncrisă.
options
NotebookSaveOptions
Specifica opțiunile modul în care documentul este salvat în fișier.
Exceptions
IncorrectDocumentStructureException
Structura documentului încalcă specificația.
UnsupportedSaveFormatException
Formatul de salvare solicitat nu este susținut.
Save(Articole cu eticheta NotebookSaveOptions)
Salvează documentul OneNote într-un flux folosind opțiunile de salvare specificate.
public void Save(Stream stream, NotebookSaveOptions options)
Parameters
stream
Stream
şi fluxul .
options
NotebookSaveOptions
Specificați opțiunile modul în care este salvat documentul.
Exceptions
IncorrectDocumentStructureException
Structura documentului încalcă specificația.
UnsupportedSaveFormatException
Formatul de salvare solicitat nu este susținut.