Class Notebook
名称: Aspose.Note 集合: Aspose.Note.dll (25.4.0)
代表一个 Aspose.Note 笔记本电脑。
public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable
Inheritance
Implements
INotebookChildNode
,
IEnumerable
继承人
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
如何保存笔记本
// 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);
显示如何在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);
显示如何保存笔记本作为图像。
// 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);
显示如何从笔记本中获取所有文本。
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>
显示如何在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
});
展示如何通过笔记本电脑的文件以轻松地加载。
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>
显示如何将新部分添加到笔记本电脑中。
// 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);
显示如何从流中加载笔记本。
// 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");
显示如何创建加密笔记本
// 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" });
显示如何保存笔记本作为图像与指定的选项。
// 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);
显示如何保存闪光笔记本作为图像。
// 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);
显示如何从笔记本电脑中删除一个部分。
// 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>
显示如何通过笔记本电脑的预载文件进行 iterate。
// 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>
展示如何通过笔记本的内容。
// 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()
启动 Aspose.Note.Notebook 类的新例子。
public Notebook()
Notebook(线条)
启动 Aspose.Note.Notebook 类的新例子。从文件中打开现有 OneNote 笔记本电脑。
public Notebook(string filePath)
Parameters
filePath
string
文件路径。
Notebook(字符串, NotebookLoadOptions)
启动 Aspose.Note.Notebook 类的新例子。从文件中打开现有 OneNote 笔记本电脑. 允许指定额外的选项,如儿童加载策略(“轻松”/即时)。
public Notebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
文件路径。
loadOptions
NotebookLoadOptions
负载选项。
Notebook(Stream)
启动 Aspose.Note.Notebook 类的新例子。从流中打开现有 OneNote 笔记本电脑。
public Notebook(Stream stream)
Parameters
stream
Stream
流的。
Notebook(流,笔记本LoadOptions)
启动 Aspose.Note.Notebook 类的新例子。从流中打开现有 OneNote 笔记本电脑,允许指定额外的加载选项。
public Notebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
流的。
loadOptions
NotebookLoadOptions
负载选项。
Properties
Color
收取或设置颜色。
public Color Color { get; set; }
财产价值
Count
获取在 Aspose.Note.笔记本中包含的元素数量。
public int Count { get; }
财产价值
DisplayName
接收或设置显示名称。
public string DisplayName { get; set; }
财产价值
Examples
显示如何从笔记本电脑中删除一个部分。
// 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
获取文件格式(OneNote 2010, OneNota Online)。
public FileFormat FileFormat { get; }
财产价值
Guid
获得对象的全球独特ID。
public Guid Guid { get; }
财产价值
IsHistoryEnabled
收到或设置一个值,表明历史是否已启用。
public bool IsHistoryEnabled { get; set; }
财产价值
这个[因特]
通过指数获得笔记本子节点。
public INotebookChildNode this[int index] { get; }
财产价值
Methods
AppendChild(圖片來源ChildNode)
将节点添加到列表的尽头。
public INotebookChildNode AppendChild(INotebookChildNode newChild)
Parameters
newChild
INotebookChildNode
添加的节点。
Returns
添加节点。
GetChildNodes()
根据节点类型获取所有儿童节。
public IList<t1> GetChildNodes<t1>() where T1 : Node
Returns
儿童节点列表
类型参数
T1
返回列表中的元素类型。
GetEnumerator()
返回通过 Aspose.Note.Notebook 的儿童节点的列表器。
public IEnumerator<inotebookchildnode> GetEnumerator()
Returns
IEnumerator < INotebookChildNode >
编辑: 收藏器 / IENUMERATOR
LoadChildDocument(线条)
添加儿童文档节点。从文件中打开现有 OneNote 文档。
public void LoadChildDocument(string filePath)
Parameters
filePath
string
文件路径。
Examples
显示如何从流中加载笔记本。
// 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(字符串, LoadOptions)
添加儿童文档节点。从文件中打开现有 OneNote 文档. 允许指定额外的加载选项。
public void LoadChildDocument(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
文件路径。
loadOptions
LoadOptions
负载选项。
LoadChildDocument(Stream)
添加儿童文档节点。从流中打开现有 OneNote 文档。
public void LoadChildDocument(Stream stream)
Parameters
stream
Stream
流的。
Examples
显示如何从流中加载笔记本。
// 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(流量, LoadOptions)
添加儿童文档节点。从流中打开现有 OneNote 文档. 允许指定额外的加载选项。
public void LoadChildDocument(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
流的。
loadOptions
LoadOptions
负载选项。
LoadChildNotebook(线条)
添加儿童笔记本节点。从文件中打开现有 OneNote 笔记本电脑。
public void LoadChildNotebook(string filePath)
Parameters
filePath
string
文件路径。
LoadChildNotebook(字符串, NotebookLoadOptions)
添加儿童笔记本节点。从文件中打开现有 OneNote 笔记本电脑. 允许指定额外的加载选项。
public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
文件路径。
loadOptions
NotebookLoadOptions
负载选项。
LoadChildNotebook(Stream)
添加儿童笔记本节点。从流中打开现有 OneNote 笔记本电脑。
public void LoadChildNotebook(Stream stream)
Parameters
stream
Stream
流的。
LoadChildNotebook(流,笔记本LoadOptions)
添加儿童笔记本节点。从流中打开现有 OneNote 笔记本电脑,允许指定额外的加载选项。
public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
流的。
loadOptions
NotebookLoadOptions
负载选项。
RemoveChild(圖片來源ChildNode)
取出孩子的节点。
public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
Parameters
oldChild
INotebookChildNode
要取消的节点。
Returns
除去的节点。
Examples
显示如何从笔记本电脑中访问所有部分。
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>
显示如何从笔记本电脑中删除一个部分。
// 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>
如何保存笔记本
// 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(线条)
将 OneNote 文档存储到文件中。
public void Save(string fileName)
Parameters
fileName
string
文件的完整名称 如果已有指定的全名文件,则已存在的文件将被过写。
Exceptions
IncorrectDocumentStructureException
文件结构违反了规格。
UnsupportedSaveFormatException
请求保存格式不支持。
Save(Stream)
将 OneNote 文档存储到流。
public void Save(Stream stream)
Parameters
stream
Stream
流的。
Exceptions
IncorrectDocumentStructureException
文件结构违反了规格。
UnsupportedSaveFormatException
请求保存格式不支持。
Save(字符串,SaveFormat)
将 OneNote 文档存储到指定格式的文件中。
public void Save(string fileName, SaveFormat format)
Parameters
fileName
string
文件的完整名称 如果已有指定的全名文件,则已存在的文件将被过写。
format
SaveFormat
保存文档的格式。
Exceptions
IncorrectDocumentStructureException
文件结构违反了规格。
UnsupportedSaveFormatException
请求保存格式不支持。
Save(流量,SaveFormat)
将 OneNote 文档存储到指定的格式中的流。
public void Save(Stream stream, SaveFormat format)
Parameters
stream
Stream
流的。
format
SaveFormat
保存文档的格式。
Exceptions
IncorrectDocumentStructureException
文件结构违反了规格。
UnsupportedSaveFormatException
请求保存格式不支持。
Save(字符串, NotebookSaveOptions)
将 OneNote 文档保存到文件中,使用所指定的保存选项。
public void Save(string fileName, NotebookSaveOptions options)
Parameters
fileName
string
文件的完整名称 如果已有指定的全名文件,则已存在的文件将被过写。
options
NotebookSaveOptions
指定文件存储方式的选项。
Exceptions
IncorrectDocumentStructureException
文件结构违反了规格。
UnsupportedSaveFormatException
请求保存格式不支持。
Save(流,笔记本SaveOptions)
将 OneNote 文档存储到一个流,使用所指定的保存选项。
public void Save(Stream stream, NotebookSaveOptions options)
Parameters
stream
Stream
流的。
options
NotebookSaveOptions
指定如何保存文档的选项。
Exceptions
IncorrectDocumentStructureException
文件结构违反了规格。
UnsupportedSaveFormatException
请求保存格式不支持。