Class Notebook
De naam: Aspose.Note Verzameling: Aspose.Note.dll (25.4.0)
Het is een Aspose.Note notebook.
public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable
Inheritance
Implements
INotebookChildNode
,
IEnumerable
Geëerbiede leden
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Zie hoe je een notebook kunt redden.
// 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);
Zie hoe je een notebook in pdf-formaat kunt opslaan.
// 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);
Laat zien hoe je een notebook als afbeelding kunt redden.
// 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);
Toon hoe je alle tekst van een notebook kunt krijgen.
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>
Toon hoe je een flatened notebook in pdf-formaat kunt opslaan.
// 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
});
Het laat zien hoe je iterateert door documenten van een notebook die ze lastig 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>
Toon hoe u een nieuwe sectie toevoegt aan een 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);
Toon hoe je een notebook uit een stroom kunt laden.
// 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");
Het laat zien hoe je een gecodeerde notebook kunt maken.
// 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" });
Toon hoe je een notebook als afbeelding kunt opslaan met aangegeven opties.
// 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);
Toon hoe je een flatened notebook als afbeelding kunt redden.
// 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);
Toon hoe je een sectie van een notebook kunt verwijderen.
// 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>
Toon hoe u iterate kunt maken door middel van vooraf geladen documenten van een 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>
Laat zien hoe je de inhoud van een notebook doorgaat.
// 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()
Initialiseert een nieuwe instantie van de Aspose.Note.Notebook-klasse.
public Notebook()
Notebook(String)
Initialiseert een nieuwe instantie van de Aspose.Note.Notebook-klasse.Open een bestaande OneNote notebook uit een bestand.
public Notebook(string filePath)
Parameters
filePath
string
De file route.
Notebook(Schakel, NotebookLoadOptions)
Initialiseert een nieuwe instantie van de Aspose.Note.Notebook-klasse.Open een bestaande OneNote-laptop van een bestand. Toegeeft u extra opties zoals een kinderloadingstrategie (“lazy”/instant) aan te geven.
public Notebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
De file route.
loadOptions
NotebookLoadOptions
De lading opties.
Notebook(Stream)
Initialiseert een nieuwe instantie van de Aspose.Note.Notebook-klasse.Open een bestaande OneNote-notebook vanuit een stroom.
public Notebook(Stream stream)
Parameters
stream
Stream
De stroom.
Notebook(Stream, NotebookLoadOptions)
Initialiseert een nieuwe instantie van de Aspose.Note.Notebook-klasse.Open een bestaande OneNote-notebook van een stroom. Toegeeft u toevoegingsopties aan te geven.
public Notebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
De stroom.
loadOptions
NotebookLoadOptions
De lading opties.
Properties
Color
Krijg of zet de kleur.
public Color Color { get; set; }
Eigendomswaarde
Count
Geeft het aantal elementen dat is opgenomen in het Aspose.Note.Notebook.
public int Count { get; }
Eigendomswaarde
DisplayName
Geeft of zet de displaynaam.
public string DisplayName { get; set; }
Eigendomswaarde
Examples
Toon hoe je een sectie van een notebook kunt verwijderen.
// 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
Geeft bestandsformaat (OneNote 2010, OneNota Online).
public FileFormat FileFormat { get; }
Eigendomswaarde
Guid
Geeft het wereldwijd uniek ID van het object.
public Guid Guid { get; }
Eigendomswaarde
IsHistoryEnabled
Geeft of stelt een waarde aan om aan te geven of de geschiedenis is ingeschakeld.
public bool IsHistoryEnabled { get; set; }
Eigendomswaarde
Dit is[Int]
Geeft een notebook kind node door de gegeven index.
public INotebookChildNode this[int index] { get; }
Eigendomswaarde
Methods
AppendChild(InschrijvingChildNode)
Voeg de knop toe aan het einde van de lijst.
public INotebookChildNode AppendChild(INotebookChildNode newChild)
Parameters
newChild
INotebookChildNode
De node om toe te voegen.
Returns
De toegevoegde node.
GetChildNodes()
Krijg alle kinderknoten volgens de node type.
public IList<t1> GetChildNodes<t1>() where T1 : Node
Returns
Een lijst van kinderknoten.
Typen Parameters
T1
Het type elementen in de geretourneerde lijst.
GetEnumerator()
Terugkomt een lijstje die door de kinderknoten van het Aspose.Note.Notebook itereert.
public IEnumerator<inotebookchildnode> GetEnumerator()
Returns
IEnumerator < INotebookChildNode >
Een systeem.Collections.IEnumerator
LoadChildDocument(String)
Voeg een kinderdocument node toe.Open een bestaande OneNote-document uit een bestand.
public void LoadChildDocument(string filePath)
Parameters
filePath
string
De file route.
Examples
Toon hoe je een notebook uit een stroom kunt laden.
// 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)
Voeg een kinderdocument node toe.Open een bestaande OneNote-document van een bestand. Toegeeft u toevoegingsopties aan te geven.
public void LoadChildDocument(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
De file route.
loadOptions
LoadOptions
De lading opties.
LoadChildDocument(Stream)
Voeg een kinderdocument node toe.Open een bestaande OneNote-document vanuit een stroom.
public void LoadChildDocument(Stream stream)
Parameters
stream
Stream
De stroom.
Examples
Toon hoe je een notebook uit een stroom kunt laden.
// 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, LoadOptions)
Voeg een kinderdocument node toe.Open een bestaande OneNote-document van een stroom. Toegeeft u toevoegingsopties aan te geven.
public void LoadChildDocument(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
De stroom.
loadOptions
LoadOptions
De lading opties.
LoadChildNotebook(String)
Voeg een kindernote-node toe.Open een bestaande OneNote notebook uit een bestand.
public void LoadChildNotebook(string filePath)
Parameters
filePath
string
De file route.
LoadChildNotebook(Schakel, NotebookLoadOptions)
Voeg een kindernote-node toe.Open een bestaande OneNote notebook van een bestand. Toegeeft u toevoegingsopties aan te geven.
public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
De file route.
loadOptions
NotebookLoadOptions
De lading opties.
LoadChildNotebook(Stream)
Voeg een kindernote-node toe.Open een bestaande OneNote-notebook vanuit een stroom.
public void LoadChildNotebook(Stream stream)
Parameters
stream
Stream
De stroom.
LoadChildNotebook(Stream, NotebookLoadOptions)
Voeg een kindernote-node toe.Open een bestaande OneNote-notebook vanuit een stroom. Toegeeft u toevoegingsopties aan te geven.
public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
De stroom.
loadOptions
NotebookLoadOptions
De lading opties.
RemoveChild(InschrijvingChildNode)
Verwijder de kinderknop.
public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
Parameters
oldChild
INotebookChildNode
De knop om te verwijderen.
Returns
De verwijderde node.
Examples
Toon hoe je alle secties van een notebook kunt bereiken.
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>
Toon hoe je een sectie van een notebook kunt verwijderen.
// 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>
Zie hoe je een notebook kunt besparen.
// 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)
Speel het OneNote-document in een bestand.
public void Save(string fileName)
Parameters
fileName
string
Als een bestand met de aangegeven volledige naam al bestaat, wordt de bestaande bestanden overgeschreven.
Exceptions
IncorrectDocumentStructureException
De structuur van het document schendt de specificatie.
UnsupportedSaveFormatException
Het verzochte save format wordt niet ondersteund.
Save(Stream)
Speel het OneNote-document in een stroom.
public void Save(Stream stream)
Parameters
stream
Stream
De stroom.
Exceptions
IncorrectDocumentStructureException
De structuur van het document schendt de specificatie.
UnsupportedSaveFormatException
Het verzochte save format wordt niet ondersteund.
Save(String en SaveFormat)
Speel het OneNote-document op een bestand in het aangegeven formaat.
public void Save(string fileName, SaveFormat format)
Parameters
fileName
string
Als een bestand met de aangegeven volledige naam al bestaat, wordt de bestaande bestanden overgeschreven.
format
SaveFormat
Het formaat waarin het document moet worden opgeslagen.
Exceptions
IncorrectDocumentStructureException
De structuur van het document schendt de specificatie.
UnsupportedSaveFormatException
Het verzochte save format wordt niet ondersteund.
Save(Stream en SaveFormat)
Speelt het OneNote-document naar een stroom in het aangegeven formaat.
public void Save(Stream stream, SaveFormat format)
Parameters
stream
Stream
De stroom.
format
SaveFormat
Het formaat waarin het document moet worden opgeslagen.
Exceptions
IncorrectDocumentStructureException
De structuur van het document schendt de specificatie.
UnsupportedSaveFormatException
Het verzochte save format wordt niet ondersteund.
Save(Schakel, NotebookSaveOptions)
Speel het OneNote-document naar een bestand met behulp van de gespecificeerde opties.
public void Save(string fileName, NotebookSaveOptions options)
Parameters
fileName
string
Als een bestand met de aangegeven volledige naam al bestaat, wordt de bestaande bestanden overgeschreven.
options
NotebookSaveOptions
Specificeert de opties hoe het document wordt opgeslagen in het bestand.
Exceptions
IncorrectDocumentStructureException
De structuur van het document schendt de specificatie.
UnsupportedSaveFormatException
Het verzochte save format wordt niet ondersteund.
Save(Stream, NotebookSaveOptions)
Speel het OneNote-document naar een stroom met behulp van de aangegeven opties voor het opslaan.
public void Save(Stream stream, NotebookSaveOptions options)
Parameters
stream
Stream
De stroom.
options
NotebookSaveOptions
Bepaal de opties hoe het document wordt opgeslagen.
Exceptions
IncorrectDocumentStructureException
De structuur van het document schendt de specificatie.
UnsupportedSaveFormatException
Het verzochte save format wordt niet ondersteund.