Class Notebook

Class Notebook

名称: Aspose.Note 集合: Aspose.Note.dll (25.4.0)

代表一个 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

object Notebook

Implements

INotebookChildNode , IEnumerable , IEnumerable

继承人

object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

如何保存笔记本

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook();
   dataDir += "test_out.onetoc2";
   notebook.Save(dataDir);

显示如何在PDF格式保存笔记本。

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
   dataDir += "ConvertToPDF_out.pdf";
   notebook.Save(dataDir);

显示如何保存笔记本作为图像。

string dataDir = RunExamples.GetDataDir_NoteBook();
   var notebook = new Notebook(dataDir + "Notizbuch Öffnen.onetoc2");
   dataDir += "ConvertToImage_out.png";
   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);
   }

显示如何在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
       });

展示如何通过笔记本电脑的文件以轻松地加载。

string inputFile = "Notizbuch öffnen.onetoc2";
   string dataDir = RunExamples.GetDataDir_NoteBook();
   Notebook notebook = new Notebook(dataDir + inputFile);
   foreach (var notebookChildNode in notebook.OfType<Document>())
   {
   }

显示如何将新部分添加到笔记本电脑中。

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);

显示如何从流中加载笔记本。

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");

显示如何创建加密笔记本

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" });

显示如何保存笔记本作为图像与指定的选项。

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);

显示如何保存闪光笔记本作为图像。

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);

显示如何从笔记本电脑中删除一个部分。

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);

显示如何通过笔记本电脑的预载文件进行 iterate。

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>())
   {
   }

展示如何通过笔记本的内容。

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

笔记本( )

启动 Aspose.Note.Notebook 类的新例子。

public Notebook()
   {
   }

笔记本(String)

启动 Aspose.Note.Notebook 类的新例子。从文件中打开现有 OneNote 笔记本电脑。

public Notebook(string filePath)
   {
   }

Parameters

filePath string

文件路径。

笔记本(string, NotebookLoadOptions)

启动 Aspose.Note.Notebook 类的新例子。从文件中打开现有 OneNote 笔记本电脑. 允许指定额外的选项,如儿童加载策略(“轻松”/即时)。

public Notebook(string filePath, NotebookLoadOptions loadOptions)
   {
   }

Parameters

filePath string

文件路径。

loadOptions NotebookLoadOptions

负载选项。

笔记本(Stream)

启动 Aspose.Note.Notebook 类的新例子。从流中打开现有 OneNote 笔记本电脑。

public class Notebook
   {
      public Notebook(Stream stream)
      {
      }
   }

Parameters

stream Stream

流的。

笔记本(流量,筆記本充電選項)

启动 Aspose.Note.Notebook 类的新例子。从流中打开现有 OneNote 笔记本电脑,允许指定额外的加载选项。

public Notebook(Stream stream, NotebookLoadOptions loadOptions)
   {
   }

Parameters

stream Stream

流的。

loadOptions NotebookLoadOptions

负载选项。

Properties

Color

收取或设置颜色。

public Color Color
   {
      get
      {
         return this.Color;
      }
      set
      {
         this.Color = value;
      }
   }

财产价值

Color

Count

获取在 Aspose.Note.笔记本中包含的元素数量。

public int Count
   {
      get;
   }

财产价值

int

DisplayName

接收或设置显示名称。

public string DisplayName
   {
      get;
      set;
   }

财产价值

string

Examples

显示如何从笔记本电脑中删除一个部分。

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

获取文件格式(OneNote 2010, OneNota Online)。

public FileFormat FileFormat
   {
      get;
   }

财产价值

FileFormat

Guid

获得对象的全球独特ID。

public Guid Guid
   {
      get;
   }

财产价值

Guid

IsHistoryEnabled

收到或设置一个值,表明历史是否已启用。

public bool IsHistoryEnabled
   {
      get;
      set;
   }

财产价值

bool

这个[因特)

通过指数获得笔记本子节点。

public INotebookChildNode this[int index]
   {
      get;
   }

财产价值

INotebookChildNode

Methods

圖片來源:InotebookChildNode

将节点添加到列表的尽头。

public INotebookChildNode AppendChild(INotebookChildNode newChild)
   {
      return _notebook.AppendChild(newChild);
   }

Parameters

newChild INotebookChildNode

添加的节点。

Returns

INotebookChildNode

添加节点。

GetChildNodes()

根据节点类型获取所有儿童节。

public IList<T1> GetChildNodes<T1>() where T1 : Node
    {
    }

Returns

IList

儿童节点列表

类型参数

T1

返回列表中的元素类型。

编号( )

返回通过 Aspose.Note.Notebook 的儿童节点的列表器。

public IEnumerator<notebookchildnode> GetEnumerator()
   {
   }

Returns

IEnumerator < INotebookChildNode >

编辑: 收藏器 / IENUMERATOR

LoadChildDocument(英格兰)

添加儿童文档节点。从文件中打开现有 OneNote 文档。

public void LoadChildDocument(string filePath)
   {
   }

Parameters

filePath string

文件路径。

Examples

显示如何从流中加载笔记本。

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)

添加儿童文档节点。从文件中打开现有 OneNote 文档. 允许指定额外的加载选项。

public void LoadChildDocument(string filePath, Aspose.Words.LoadOptions loadOptions)
   {
   }

Parameters

filePath string

文件路径。

loadOptions LoadOptions

负载选项。

LoadChildDocument(流)

添加儿童文档节点。从流中打开现有 OneNote 文档。

public void LoadChildDocument(Stream stream)
   {
   }

Parameters

stream Stream

流的。

Examples

显示如何从流中加载笔记本。

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(注,笔记本LoadOptions)

添加儿童笔记本节点。从文件中打开现有 OneNote 笔记本电脑. 允许指定额外的加载选项。

public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
   {
   }

Parameters

filePath string

文件路径。

loadOptions NotebookLoadOptions

负载选项。

LoadChildNotebook(流)

添加儿童笔记本节点。从流中打开现有 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(INotebookChilm)

取出孩子的节点。

public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
   {
   }

Parameters

oldChild INotebookChildNode

要取消的节点。

Returns

INotebookChildNode

除去的节点。

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);
   }

显示如何从笔记本电脑中删除一个部分。

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);

如何保存笔记本

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" });
   }

保存(String)

将 OneNote 文档存储到文件中。

public void Save(string fileName)
   {
   }

Parameters

fileName string

文件的完整名称 如果已有指定的全名文件,则已存在的文件将被过写。

Exceptions

IncorrectDocumentStructureException

文件结构违反了规格。

UnsupportedSaveFormatException

请求保存格式不支持。

播放(Save)

将 OneNote 文档存储到流。

public void Save(Stream stream)
   {
   }

Parameters

stream Stream

流的。

Exceptions

IncorrectDocumentStructureException

文件结构违反了规格。

UnsupportedSaveFormatException

请求保存格式不支持。

保存(string、SaveFormat)

将 OneNote 文档存储到指定格式的文件中。

public void Save(string fileName, Aspose.Words.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

请求保存格式不支持。

保存(string, NotebookSaveOptions)

将 OneNote 文档保存到文件中,使用所指定的保存选项。

public void Save(string fileName, NotebookSaveOptions options)
   {
   }

Parameters

fileName string

文件的完整名称 如果已有指定的全名文件,则已存在的文件将被过写。

options NotebookSaveOptions

指定文件存储方式的选项。

Exceptions

IncorrectDocumentStructureException

文件结构违反了规格。

UnsupportedSaveFormatException

请求保存格式不支持。

保存(流,笔记本保存选项)

将 OneNote 文档存储到一个流,使用所指定的保存选项。

public void Save(Stream stream, NotebookSaveOptions options)
   {
   }

Parameters

stream Stream

流的。

options NotebookSaveOptions

指定如何保存文档的选项。

Exceptions

IncorrectDocumentStructureException

文件结构违反了规格。

UnsupportedSaveFormatException

请求保存格式不支持。

 中文