Class Notebook
Nome do espaço: Aspose.Note Assembleia: Aspose.Note.dll (25.4.0)
Representa um Aspose.Note notebook.
public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable
Inheritance
Implements
INotebookChildNode
,
IEnumerable
Membros herdados
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Descubra como salvar um 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 como salvar um notebook em 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 como salvar o notebook como imagem.
// 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 como obter todo o texto de um 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 como salvar um notebook em 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 como iterar através de documentos de um notebook carregando-os suavemente.
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 como adicionar uma nova seção a um 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 como carregar um notebook de uma corrente.
// 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 como fazer um notebook criptografado.
// 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 como salvar o notebook como imagem com opções especificadas.
// 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 como salvar um notebook flatulente como imagem.
// 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 como remover uma seção de um 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 como iterar através de documentos pré-carregados de um 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 como passar pelo conteúdo de um 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()
Inicia uma nova instância da classe Aspose.Note.Notebook.
public Notebook()
Notebook(Redação)
Inicia uma nova instância da classe Aspose.Note.Notebook.Abra um notebook OneNote existente de um arquivo.
public Notebook(string filePath)
Parameters
filePath
string
O caminho do arquivo.
Notebook(Título: NotebookLoadOptions)
Inicia uma nova instância da classe Aspose.Note.Notebook.Abrir um notebook OneNote existente a partir de um arquivo. permite especificar opções adicionais, como uma estratégia de carregamento infantil (“lazy” / instant).
public Notebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
O caminho do arquivo.
loadOptions
NotebookLoadOptions
As opções de carga.
Notebook(Stream)
Inicia uma nova instância da classe Aspose.Note.Notebook.Abra um notebook OneNote existente a partir de um fluxo.
public Notebook(Stream stream)
Parameters
stream
Stream
e o fluxo.
Notebook(Título: NotebookLoadOptions)
Inicia uma nova instância da classe Aspose.Note.Notebook.Abra um notebook OneNote existente a partir de um fluxo. permite especificar opções adicionais de carregamento.
public Notebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
e o fluxo.
loadOptions
NotebookLoadOptions
As opções de carga.
Properties
Color
Faça ou coloca a cor.
public Color Color { get; set; }
Valor da propriedade
Count
Recebe o número de elementos contidos no Aspose.Note.Notebook.
public int Count { get; }
Valor da propriedade
DisplayName
Receba ou coloca o nome do display.
public string DisplayName { get; set; }
Valor da propriedade
Examples
Mostra como remover uma seção de um 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
Obtenha o formato de arquivo (OneNote 2010, OneNota Online).
public FileFormat FileFormat { get; }
Valor da propriedade
Guid
Obtenha o ID único global do objeto.
public Guid Guid { get; }
Valor da propriedade
IsHistoryEnabled
Recebe ou coloca um valor indicando se a história é ativada.
public bool IsHistoryEnabled { get; set; }
Valor da propriedade
Esta[Int]
Recebe o nodo de bebê do notebook pelo índice dado.
public INotebookChildNode this[int index] { get; }
Valor da propriedade
Methods
AppendChild(LivroChildNode)
Adicione o nodo ao final da lista.
public INotebookChildNode AppendChild(INotebookChildNode newChild)
Parameters
newChild
INotebookChildNode
O nodo para adicionar.
Returns
O nodo adicionado.
Título: GetChildNodes()
Obtenha todos os nodos da criança pelo tipo de nodo.
public IList<t1> GetChildNodes<t1>() where T1 : Node
Returns
Uma lista de nodos da criança.
Tipo de Parâmetros
T1
Tipo de elementos na lista devolvida.
GetEnumerator()
Retorna um enumerador que itera através dos nódulos infantis do Aspose.Note.Notebook.
public IEnumerator<inotebookchildnode> GetEnumerator()
Returns
IEnumerator e o PT; INotebookChildNode >
Um sistema.Colecções.IEnumerador
LoadChildDocument(Redação)
Adicione um nodo de documento infantil.Abra um documento do OneNote existente a partir de um arquivo.
public void LoadChildDocument(string filePath)
Parameters
filePath
string
O caminho do arquivo.
Examples
Mostra como carregar um notebook de uma corrente.
// 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(Título: LoadOptions)
Adicione um nodo de documento infantil.Abra um documento do OneNote existente de um arquivo. permite especificar opções adicionais de carregamento.
public void LoadChildDocument(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
O caminho do arquivo.
loadOptions
LoadOptions
As opções de carga.
LoadChildDocument(Stream)
Adicione um nodo de documento infantil.Abra um documento do OneNote existente a partir de um fluxo.
public void LoadChildDocument(Stream stream)
Parameters
stream
Stream
e o fluxo.
Examples
Mostra como carregar um notebook de uma corrente.
// 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(Transmissão, LoadOptions)
Adicione um nodo de documento infantil.Abra um documento do OneNote existente a partir de um fluxo. permite especificar opções adicionais de carregamento.
public void LoadChildDocument(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
e o fluxo.
loadOptions
LoadOptions
As opções de carga.
LoadChildNotebook(Redação)
Adicione um nodo de notebook infantil.Abra um notebook OneNote existente de um arquivo.
public void LoadChildNotebook(string filePath)
Parameters
filePath
string
O caminho do arquivo.
LoadChildNotebook(Título: NotebookLoadOptions)
Adicione um nodo de notebook infantil.Abra um notebook OneNote existente a partir de um arquivo. permite especificar opções adicionais de carregamento.
public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
O caminho do arquivo.
loadOptions
NotebookLoadOptions
As opções de carga.
LoadChildNotebook(Stream)
Adicione um nodo de notebook infantil.Abra um notebook OneNote existente a partir de um fluxo.
public void LoadChildNotebook(Stream stream)
Parameters
stream
Stream
e o fluxo.
LoadChildNotebook(Título: NotebookLoadOptions)
Adicione um nodo de notebook infantil.Abra um notebook OneNote existente a partir de um fluxo. permite especificar opções adicionais de carregamento.
public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
e o fluxo.
loadOptions
NotebookLoadOptions
As opções de carga.
RemoveChild(LivroChildNode)
Remova o nodo da criança.
public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
Parameters
oldChild
INotebookChildNode
O nodo para remover.
Returns
O nodo removido.
Examples
Mostra como acessar todas as seções de um 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 como remover uma seção de um 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 como salvar um 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(Redação)
Salve o documento do OneNote para um arquivo.
public void Save(string fileName)
Parameters
fileName
string
Se um ficheiro com o nome completo especificado já existe, o arquivo existente é sobreescrito.
Exceptions
IncorrectDocumentStructureException
A estrutura do documento viola a especificação.
UnsupportedSaveFormatException
O formato de armazenamento solicitado não é suportado.
Save(Stream)
Salve o documento do OneNote para um fluxo.
public void Save(Stream stream)
Parameters
stream
Stream
e o fluxo.
Exceptions
IncorrectDocumentStructureException
A estrutura do documento viola a especificação.
UnsupportedSaveFormatException
O formato de armazenamento solicitado não é suportado.
Save(Título: SaveFormat)
Salve o documento do OneNote para um arquivo no formato especificado.
public void Save(string fileName, SaveFormat format)
Parameters
fileName
string
Se um ficheiro com o nome completo especificado já existe, o arquivo existente é sobreescrito.
format
SaveFormat
O formato em que salvar o documento.
Exceptions
IncorrectDocumentStructureException
A estrutura do documento viola a especificação.
UnsupportedSaveFormatException
O formato de armazenamento solicitado não é suportado.
Save(Armazém, SaveFormat)
Salve o documento do OneNote para um fluxo no formato especificado.
public void Save(Stream stream, SaveFormat format)
Parameters
stream
Stream
e o fluxo.
format
SaveFormat
O formato em que salvar o documento.
Exceptions
IncorrectDocumentStructureException
A estrutura do documento viola a especificação.
UnsupportedSaveFormatException
O formato de armazenamento solicitado não é suportado.
Save(Título: NotebookSaveOptions)
Salve o documento do OneNote para um arquivo usando as opções de salvo especificadas.
public void Save(string fileName, NotebookSaveOptions options)
Parameters
fileName
string
Se um ficheiro com o nome completo especificado já existe, o arquivo existente é sobreescrito.
options
NotebookSaveOptions
Determina as opções de como o documento é salvo no arquivo.
Exceptions
IncorrectDocumentStructureException
A estrutura do documento viola a especificação.
UnsupportedSaveFormatException
O formato de armazenamento solicitado não é suportado.
Save(Armazém, NotebookSaveOptions)
Salve o documento do OneNote para um fluxo usando as opções de salvo especificadas.
public void Save(Stream stream, NotebookSaveOptions options)
Parameters
stream
Stream
e o fluxo.
options
NotebookSaveOptions
Determina as opções de como o documento é salvo.
Exceptions
IncorrectDocumentStructureException
A estrutura do documento viola a especificação.
UnsupportedSaveFormatException
O formato de armazenamento solicitado não é suportado.