Class Notebook
Pôvodný názov: Aspose.Note Zhromaždenie: Aspose.Note.dll (25.4.0)
Predstavuje Aspose.Note notebook.
public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable
Inheritance
Implements
INotebookChildNode
,
IEnumerable
Z dedičných členov
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
Ukážte, ako ušetriť 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);
Ukážte, ako uložiť notebook vo formáte 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);
Ukážte, ako uložiť notebook ako obrázok.
// 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);
Ukáže, ako získať celý text z notebooku.
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>
Ukážte, ako uložiť platený notebook vo formáte 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
});
Ukáže, ako iterovať dokumenty z notebooku, ktoré ich ľahko nabíjajú.
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>
Ukážte, ako pridať novú sekciu do notebooku.
// 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);
Ukázať, ako načítať notebook z prúdu.
// 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");
Ukážte, ako vytvoriť šifrovaný notebook.
// 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" });
Ukáže, ako uložiť notebook ako obrázok so špecifikovanými možnosťami.
// 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);
Ukáže, ako zachrániť pletený notebook ako obrázok.
// 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);
Ukáže, ako odstrániť sekciu z notebooku.
// 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>
Ukáže, ako iterovať prostredníctvom prednaložených dokumentov notebooku.
// 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>
Ukážte, ako prejsť obsahom notebooku.
// 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()
Initalizuje novú inštanciu triedy Aspose.Note.Notebook.
public Notebook()
Notebook(Stretnutie)
Initalizuje novú inštanciu triedy Aspose.Note.Notebook.Otvorí existujúci notebook OneNote z súboru.
public Notebook(string filePath)
Parameters
filePath
string
Pôvodná cesta súboru.
Notebook(Príslušenstvo pre NotebookLoadOptions)
Initalizuje novú inštanciu triedy Aspose.Note.Notebook.Otvorí existujúci notebook OneNote z súboru. Umožňuje špecifikovať ďalšie možnosti, ako je napríklad stratégia na nabíjanie detí („lazy“/instant).
public Notebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
Pôvodná cesta súboru.
loadOptions
NotebookLoadOptions
Možnosti zaťaženia .
Notebook(Stream)
Initalizuje novú inštanciu triedy Aspose.Note.Notebook.Otvorí existujúci notebook OneNote z prúdu.
public Notebook(Stream stream)
Parameters
stream
Stream
a prúdu .
Notebook(Príslušenstvo, NotebookLoadOptions)
Initalizuje novú inštanciu triedy Aspose.Note.Notebook.Otvorí existujúci notebook OneNote z prúdu. umožňuje špecifikovať ďalšie možnosti nabíjania.
public Notebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
a prúdu .
loadOptions
NotebookLoadOptions
Možnosti zaťaženia .
Properties
Color
Dostane alebo nastaví farbu.
public Color Color { get; set; }
Hodnota nehnuteľnosti
Count
Získa počet položiek obsiahnutých v Aspose.Note.Notebook.
public int Count { get; }
Hodnota nehnuteľnosti
DisplayName
Dostane alebo nastaví názov displeja.
public string DisplayName { get; set; }
Hodnota nehnuteľnosti
Examples
Ukáže, ako odstrániť sekciu z notebooku.
// 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
Získava formát súboru (OneNote 2010, OneNota Online).
public FileFormat FileFormat { get; }
Hodnota nehnuteľnosti
Guid
Získava celosvetovo jedinečný identifikátor objektu.
public Guid Guid { get; }
Hodnota nehnuteľnosti
IsHistoryEnabled
Získa alebo nastaví hodnotu, ktorá naznačuje, či je príbeh povolený.
public bool IsHistoryEnabled { get; set; }
Hodnota nehnuteľnosti
Toto[int]
Získať notebook detský uzol podľa daného indexu.
public INotebookChildNode this[int index] { get; }
Hodnota nehnuteľnosti
Methods
AppendChild(Úvodná stránkaChildNode)
Pridajte uzol na koniec zoznamu.
public INotebookChildNode AppendChild(INotebookChildNode newChild)
Parameters
newChild
INotebookChildNode
Node na pridanie.
Returns
pridaný nôž.
GetChildNodes()
Získajte všetky detské uzly podľa typu uzla.
public IList<t1> GetChildNodes<t1>() where T1 : Node
Returns
Zoznam detských uzlín.
Typ parametrov
T1
Typ položiek v vrátenom zozname.
GetEnumerator()
Vráti enumerátor, ktorý iteruje cez detské uzly Aspose.Note.Notebook.
public IEnumerator<inotebookchildnode> GetEnumerator()
Returns
IEnumerator < INotebookChildNode >
Názov: Systémy a zbierky. →
LoadChildDocument(Stretnutie)
Pridajte detský dokumentový uzol.Otvorí existujúci dokument OneNote z súboru.
public void LoadChildDocument(string filePath)
Parameters
filePath
string
Pôvodná cesta súboru.
Examples
Ukázať, ako načítať notebook z prúdu.
// 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(striekačky, LoadOptions)
Pridajte detský dokumentový uzol.Otvorí existujúci dokument OneNote z súboru. umožňuje špecifikovať ďalšie možnosti zaťaženia.
public void LoadChildDocument(string filePath, LoadOptions loadOptions)
Parameters
filePath
string
Pôvodná cesta súboru.
loadOptions
LoadOptions
Možnosti zaťaženia .
LoadChildDocument(Stream)
Pridajte detský dokumentový uzol.Otvorí existujúci dokument OneNote z prúdu.
public void LoadChildDocument(Stream stream)
Parameters
stream
Stream
a prúdu .
Examples
Ukázať, ako načítať notebook z prúdu.
// 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(Príslušenstvo, LoadOptions)
Pridajte detský dokumentový uzol.Otvorí existujúci dokument OneNote z prúdu. umožňuje špecifikovať ďalšie možnosti zaťaženia.
public void LoadChildDocument(Stream stream, LoadOptions loadOptions)
Parameters
stream
Stream
a prúdu .
loadOptions
LoadOptions
Možnosti zaťaženia .
LoadChildNotebook(Stretnutie)
Pridajte detský notebook.Otvorí existujúci notebook OneNote z súboru.
public void LoadChildNotebook(string filePath)
Parameters
filePath
string
Pôvodná cesta súboru.
LoadChildNotebook(Príslušenstvo pre NotebookLoadOptions)
Pridajte detský notebook.Otvorí existujúci notebook OneNote z súboru. umožňuje špecifikovať ďalšie možnosti zaťaženia.
public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)
Parameters
filePath
string
Pôvodná cesta súboru.
loadOptions
NotebookLoadOptions
Možnosti zaťaženia .
LoadChildNotebook(Stream)
Pridajte detský notebook.Otvorí existujúci notebook OneNote z prúdu.
public void LoadChildNotebook(Stream stream)
Parameters
stream
Stream
a prúdu .
LoadChildNotebook(Príslušenstvo, NotebookLoadOptions)
Pridajte detský notebook.Otvorí existujúci notebook OneNote z prúdu. umožňuje špecifikovať ďalšie možnosti zaťaženia.
public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)
Parameters
stream
Stream
a prúdu .
loadOptions
NotebookLoadOptions
Možnosti zaťaženia .
RemoveChild(Úvodná stránkaChildNode)
Odstráňte detský uzol.
public INotebookChildNode RemoveChild(INotebookChildNode oldChild)
Parameters
oldChild
INotebookChildNode
Node na odstránenie.
Returns
Odstránený nôž
Examples
Ukáže, ako získať prístup k všetkým sekciám z notebooku.
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>
Ukáže, ako odstrániť sekciu z notebooku.
// 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>
Ukážte, ako ušetriť 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(Stretnutie)
Uloží dokument OneNote do súboru.
public void Save(string fileName)
Parameters
fileName
string
Plný názov súboru.Ak súbory s uvedeným plným názvom už existujú, existujúci súprava sa prepisuje.
Exceptions
IncorrectDocumentStructureException
Struktúra dokumentu porušuje špecifikáciu.
UnsupportedSaveFormatException
Vyžiadaný formát sa nepodporuje.
Save(Stream)
Uloží dokument OneNote do prúdu.
public void Save(Stream stream)
Parameters
stream
Stream
a prúdu .
Exceptions
IncorrectDocumentStructureException
Struktúra dokumentu porušuje špecifikáciu.
UnsupportedSaveFormatException
Vyžiadaný formát sa nepodporuje.
Save(Strieľačka, SaveFormat)
Uloží dokument OneNote do súboru v špecifikovanom formáte.
public void Save(string fileName, SaveFormat format)
Parameters
fileName
string
Plný názov súboru.Ak súbory s uvedeným plným názvom už existujú, existujúci súprava sa prepisuje.
format
SaveFormat
Formát, v ktorom sa má dokument uložiť.
Exceptions
IncorrectDocumentStructureException
Struktúra dokumentu porušuje špecifikáciu.
UnsupportedSaveFormatException
Vyžiadaný formát sa nepodporuje.
Save(Príslušenstvo, SaveFormat)
Uloží dokument OneNote do toku v špecifikovanom formáte.
public void Save(Stream stream, SaveFormat format)
Parameters
stream
Stream
a prúdu .
format
SaveFormat
Formát, v ktorom sa má dokument uložiť.
Exceptions
IncorrectDocumentStructureException
Struktúra dokumentu porušuje špecifikáciu.
UnsupportedSaveFormatException
Vyžiadaný formát sa nepodporuje.
Save(Príslušenstvo pre NotebookSaveOptions)
Uloží dokument OneNote do súboru pomocou špecifikovaných možností ušetrenia.
public void Save(string fileName, NotebookSaveOptions options)
Parameters
fileName
string
Plný názov súboru.Ak súbory s uvedeným plným názvom už existujú, existujúci súprava sa prepisuje.
options
NotebookSaveOptions
Ukazuje možnosti, ako je dokument uložený v súbore.
Exceptions
IncorrectDocumentStructureException
Struktúra dokumentu porušuje špecifikáciu.
UnsupportedSaveFormatException
Vyžiadaný formát sa nepodporuje.
Save(Stream, NotebookSaveOptions)
Uloží dokument OneNote do toku pomocou špecifikovaných možností ušetrenia.
public void Save(Stream stream, NotebookSaveOptions options)
Parameters
stream
Stream
a prúdu .
options
NotebookSaveOptions
Určuje možnosti, ako sa dokument ukladá.
Exceptions
IncorrectDocumentStructureException
Struktúra dokumentu porušuje špecifikáciu.
UnsupportedSaveFormatException
Vyžiadaný formát sa nepodporuje.