Class Notebook
Nom dels espais: Aspose.Note Assemblea: Aspose.Note.dll (25.4.0)
Presentació d’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
Implements
INotebookChildNode
,
IEnumerable
Membres heretats
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Mostra com salvar el notebook.
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook();
dataDir += "test_out.onetoc2";
notebook.Save(dataDir);
Mostra com guardar el notebook en format PDF.
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
dataDir += "ConvertToPDF_out.pdf";
notebook.Save(dataDir);
Mostra com salvar el notebook com a imatge.
string dataDir = RunExamples.GetDataDir_NoteBook();
var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
dataDir += "ConvertToImage_out.png";
notebook.Save(dataDir);
Mostra com obtenir tot el text d’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 com guardar un notebook flatenat en format 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 com iterar a través de documents d’un notebook que els carrega lleugerament.
string inputFile = "Notizbuch öffnen.onetoc2";
string dataDir = RunExamples.GetDataDir_NoteBook();
Notebook notebook = new Notebook(dataDir + inputFile);
foreach (var notebookChildNode in notebook.OfType<Document>())
{
}
Mostra com afegir una nova secció 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 com carregar el notebook d’un corrent.
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 com fer un notebook xifrat.
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 com salvar el notebook com a imatge amb les opcions especificades.
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 com guardar un notebook flatulent com a imatge.
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 com eliminar una secció d’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 com iterar a través de documents precarregats d’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 com passar pel contingut d’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
Llibre de notícies ()
Inicialitza una nova instància de la classe Aspose.Note.
public Notebook()
{
}
Llibre de notícies (string)
Inicialitza una nova instància de la classe Aspose.Note.Obre un notebook de OneNote existent d’un arxiu.
public Notebook(string filePath)
{
}
Parameters
filePath
string
El camí del fitxer.
Notebook (string, opcions de carregament de notebook)
Inicialitza una nova instància de la classe Aspose.Note.Obre un notebook OneNote existent des d’un arxiu. permet especificar opcions addicionals com una estratègia de càrrega infantil (“lazy” / instant).
public Notebook(string filePath, NotebookLoadOptions loadOptions)
{
}
Parameters
filePath
string
El camí del fitxer.
loadOptions
NotebookLoadOptions
Opcions de càrrega.
Llista de notícies (Stream)
Inicialitza una nova instància de la classe Aspose.Note.Obre un notebook OneNote existent des d’un corrent.
public class Notebook
{
public Notebook(Stream stream)
{
}
}
Parameters
stream
Stream
El corrent.
Notebook (Stream, Opcions de càrrega de notebook)
Inicialitza una nova instància de la classe Aspose.Note.Obre un notebook OneNote existent des d’un corrent. permet especificar opcions de càrrega addicionals.
public Notebook(Stream stream, NotebookLoadOptions loadOptions)
{
}
Parameters
stream
Stream
El corrent.
loadOptions
NotebookLoadOptions
Opcions de càrrega.
Properties
Color
Obtenir o posar el color.
public Color Color
{
get
{
return this.Color;
}
set
{
this.Color = value;
}
}
Valor de la propietat
Count
Obté el nombre d’elements continguts en l’Aspose.Note.
public int Count
{
get;
}
Valor de la propietat
DisplayName
Obtenir o posar el nom de la pantalla.
public string DisplayName
{
get;
set;
}
Valor de la propietat
Examples
Mostra com eliminar una secció d’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
Obté el format de fitxers (OneNote 2010, OneNota Online).
public FileFormat FileFormat
{
get;
}
Valor de la propietat
Guid
Obté l’ID globalment únic de l’objecte.
public Guid Guid
{
get;
}
Valor de la propietat
IsHistoryEnabled
Obté o s’estableix un valor que indiqui si l’història està activada.
public bool IsHistoryEnabled
{
get;
set;
}
Valor de la propietat
Aquest[Int)
Obté el nucli infantil de la notable per l’índex donat.
public INotebookChildNode this[int index]
{
get;
}
Valor de la propietat
Methods
Programació (INotebookChildNode)
Afegeix el nucli al final de la llista.
public INotebookChildNode AppendChild(INotebookChildNode newChild)
{
return _notebook.AppendChild(newChild);
}
Parameters
newChild
INotebookChildNode
El nucli per afegir.
Returns
El nucli afegit.
GetChildNodes()
Obtenir tots els nodes infantils pel tipus de nucli.
public IList<T1> GetChildNodes<T1>() where T1 : Node
{
}
Returns
Una llista de nodes infantils.
Tipus de paràmetres
T1
El tipus d’elements de la llista retornada.
Llegir més ()
Retorna un enumerador que itera a través dels nodes infantils de l’Aspose.Note.
public IEnumerator<notebookchildnode> GetEnumerator()
{
}
Returns
IEnumerator < INotebookChildNode >
Un sistema.Col·leccions.IEnumerador
Lliurament del document (string)
Afegeix un nucli de document infantil.Obre un document OneNote existent d’un arxiu.
public void LoadChildDocument(string filePath)
{
}
Parameters
filePath
string
El camí del fitxer.
Examples
Mostra com carregar el notebook d’un corrent.
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, Opcions de càrrega)
Afegeix un nucli de document infantil.Obre un document OneNote existent d’un arxiu. permet especificar opcions de càrrega addicionals.
public void LoadChildDocument(string filePath, Aspose.Words.LoadOptions loadOptions)
{
}
Parameters
filePath
string
El camí del fitxer.
loadOptions
LoadOptions
Opcions de càrrega.
Lliurament del document (Stream)
Afegeix un nucli de document infantil.Obre un document OneNote existent des d’un corrent.
public void LoadChildDocument(Stream stream)
{
}
Parameters
stream
Stream
El corrent.
Examples
Mostra com carregar el notebook d’un corrent.
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, Opcions de càrrega)
Afegeix un nucli de document infantil.Obre un document OneNote existent des d’un flux. permet especificar opcions de càrrega addicionals.
public void LoadChildDocument(Stream stream, LoadOptions loadOptions)
{
}
Parameters
stream
Stream
El corrent.
loadOptions
LoadOptions
Opcions de càrrega.
Llibre de notícies (string)
Afegeix un núvol de notebook infantil.Obre un notebook de OneNote existent d’un arxiu.
public void LoadChildNotebook(string filePath)
{
}
Parameters
filePath
string
El camí del fitxer.
LoadChildNotebook(string, NotebookLoadOptions)
Afegeix un núvol de notebook infantil.Obre un notebook OneNote existent des d’un arxiu. permet especificar opcions de càrrega addicionals.
public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
{
}
Parameters
filePath
string
El camí del fitxer.
loadOptions
NotebookLoadOptions
Opcions de càrrega.
Llibre de notícies (Stream)
Afegeix un núvol de notebook infantil.Obre un notebook OneNote existent des d’un corrent.
public void LoadChildNotebook(Stream stream)
{
}
Parameters
stream
Stream
El corrent.
LoadChildNotebook(Stream, NotebookLoadOptions)
Afegeix un núvol de notebook infantil.Obre un notebook OneNote existent des d’un corrent. permet especificar opcions de càrrega addicionals.
public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
{
}
Parameters
stream
Stream
El corrent.
loadOptions
NotebookLoadOptions
Opcions de càrrega.
RemoveChild(INotebookNode) per a l’aplicació
Elimina el nucli del nen.
public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
{
}
Parameters
oldChild
INotebookChildNode
El nucli per eliminar.
Returns
El nucli eliminat.
Examples
Mostra com accedir a totes les seccions d’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 com eliminar una secció d’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 com salvar 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" });
}
Llegir més (string)
Salva el document OneNote a un arxiu.
public void Save(string fileName)
{
}
Parameters
fileName
string
Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.
Exceptions
IncorrectDocumentStructureException
L’estructura del document viola la especificació.
UnsupportedSaveFormatException
El format de salvament sol·licitat no es dóna suport.
El trànsit (Stream)
Salva el document OneNote a un flux.
public void Save(Stream stream)
{
}
Parameters
stream
Stream
El corrent.
Exceptions
IncorrectDocumentStructureException
L’estructura del document viola la especificació.
UnsupportedSaveFormatException
El format de salvament sol·licitat no es dóna suport.
Salvació (string, SaveFormat)
Salva el document OneNote a un arxiu en el format especificat.
public void Save(string fileName, Aspose.Words.SaveFormat format)
{
}
Parameters
fileName
string
Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.
format
SaveFormat
El format en el qual guardar el document.
Exceptions
IncorrectDocumentStructureException
L’estructura del document viola la especificació.
UnsupportedSaveFormatException
El format de salvament sol·licitat no es dóna suport.
Salvació (Stream i SaveFormat)
Salva el document OneNote a un flux en el format especificat.
public void Save(Stream stream, SaveFormat format)
{
}
Parameters
stream
Stream
El corrent.
format
SaveFormat
El format en el qual guardar el document.
Exceptions
IncorrectDocumentStructureException
L’estructura del document viola la especificació.
UnsupportedSaveFormatException
El format de salvament sol·licitat no es dóna suport.
Salvació (string, NotebookSaveOptions)
Salva el document OneNote a un arxiu utilitzant les opcions especificades.
public void Save(string fileName, NotebookSaveOptions options)
{
}
Parameters
fileName
string
Si ja existeix un arxiu amb el nom complet especificat, el fitxer existent es reescriu.
options
NotebookSaveOptions
Especifica les opcions de com s’emmagatzema el document en el fitxer.
Exceptions
IncorrectDocumentStructureException
L’estructura del document viola la especificació.
UnsupportedSaveFormatException
El format de salvament sol·licitat no es dóna suport.
Salvació (Stream, NotebookSaveOptions)
Salva el document OneNote a un flux utilitzant les opcions especificades de salvatge.
public void Save(Stream stream, NotebookSaveOptions options)
{
}
Parameters
stream
Stream
El corrent.
options
NotebookSaveOptions
Especifica les opcions de com s’emmagatzema el document.
Exceptions
IncorrectDocumentStructureException
L’estructura del document viola la especificació.
UnsupportedSaveFormatException
El format de salvament sol·licitat no es dóna suport.