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>
Показує, як ітеризувати за допомогою завантажених документів ноутбука.
// 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(ТОВАРИСТВО З ОБМЕЖЕНОЮ ВІДПОВІДАЛЬНІСТЮ)
Ініціалює нову інстанцію класу 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(Завантажити, NotebookLoadOptions)
Ініціалює нову інстанцію класу 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
Отримає глобально унікальний ідентифікатор об’єкта.
public Guid Guid { get; }
вартість нерухомості
IsHistoryEnabled
Приймає або встановлює значення, яке вказує на те, чи включена історія.
public bool IsHistoryEnabled { get; set; }
вартість нерухомості
Цей[ІНТ]
Приймає дитячий ноутбук за даним індексу.
public INotebookChildNode this[int index] { get; }
вартість нерухомості
Methods
AppendChild(Створення InotebookChildNode)
Додайте нод до кінця списку.
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 >
Створення System.Collections.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(ТОВАРИСТВО З ОБМЕЖЕНОЮ ВІДПОВІДАЛЬНІстю)
Додайте дитячий документ.Відкриває існуючий документ 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(ТОВАРИСТВО З ОБМЕЖЕНОЮ ВІДПОВІДАЛЬНІСТЮ)
Додайте дитячий ноутбук.Відкриває існуючий ноутбук 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(Завантажити, NotebookLoadOptions)
Додайте дитячий ноутбук.Відкриває існуючий ноутбук OneNote з потоку. дозволяє вказати додаткові опції завантаження.
public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
і потоку .
loadOptions
NotebookLoadOptions
Вибір опціонів навантаження.
RemoveChild(Створення InotebookChildNode)
Зніміть дитячий вузол.
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(ТОВАРИСТВО З ОБМЕЖЕНОЮ ВІДПОВІДАЛЬНІСТЮ)
Зберегти документ OneNote до файлу за допомогою визначених варіантів збереження.
public void Save(string fileName, NotebookSaveOptions options)
Parameters
fileName
string
Якщо файл з зазначеним повним ім’ям вже існує, існуючий файл переписується.
options
NotebookSaveOptions
Визначте варіанти, як документ зберігається в файлі.
Exceptions
IncorrectDocumentStructureException
Структура документа порушує специфікацію.
UnsupportedSaveFormatException
Запрошений формат збереження не підтримується.
Save(Завантажити, NotebookSaveOptions)
Зберегти документ OneNote до потоку за допомогою визначених варіантів збереження.
public void Save(Stream stream, NotebookSaveOptions options)
Parameters
stream
Stream
і потоку .
options
NotebookSaveOptions
Визначте варіанти, як зберігається документ.
Exceptions
IncorrectDocumentStructureException
Структура документа порушує специфікацію.
UnsupportedSaveFormatException
Запрошений формат збереження не підтримується.