Class Notebook

Class Notebook

Nazwa przestrzeń: Aspose.Note Zgromadzenie: Aspose.Note.dll (25.4.0)

Przedstawiamy notatkę Aspose.Note.

public class Notebook : INotebookChildNode, IEnumerable<inotebookchildnode>, IEnumerable

Inheritance

object Notebook

Implements

INotebookChildNode , IEnumerable , IEnumerable

Dziedziczeni członkowie

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

Examples

Pokaż jak zaoszczędzić notatkę.

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

Pokaż, jak zaoszczędzić notebook w formacie 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);

Pokaż, jak zaoszczędzić notebook jako obraz.

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

Pokaż, jak uzyskać cały tekst z notatki.

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>

Pokaż, jak zaoszczędzić notatkę w formacie 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
                                                                  });

Pokazuje, jak iterować za pomocą dokumentów z notatnika ładując je łagodnie.

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>

Pokaż, jak dodać nową sekcję do notatki.

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

Pokaż, jak pobierać notatkę 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");

Pokaż, jak zrobić szyfrowaną notatkę.

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

Pokaż, jak zaoszczędzić notebook jako obraz z określonymi opcjami.

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

Pokaż, jak zaoszczędzić płaski notebook jako obraz.

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

Pokaż, jak usunąć sekcję z notatki.

// 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>

Pokazuje, jak iterować za pośrednictwem przedładowanych dokumentów notatora.

// 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>

Pokaż, jak przejść przez treść notatki.

// 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()

Inicjalizuje nową instancję klasy Aspose.Note.Notebook.

public Notebook()

Notebook(strumień)

Inicjalizuje nową instancję klasy Aspose.Note.Notebook.Otwórz istniejący notebook OneNote z pliku.

public Notebook(string filePath)

Parameters

filePath string

Droga do pliku.

Notebook(Tłumaczenia, NotebookLoadOptions)

Inicjalizuje nową instancję klasy Aspose.Note.Notebook.Otwiera istniejący notebook OneNote z pliku. pozwala określić dodatkowe opcje, takie jak strategia ładowania dla dzieci („lazy”/instant).

public Notebook(string filePath, NotebookLoadOptions loadOptions)

Parameters

filePath string

Droga do pliku.

loadOptions NotebookLoadOptions

Opcje opcji ładowania.

Notebook(Stream)

Inicjalizuje nową instancję klasy Aspose.Note.Notebook.Otwórz istniejący notebook OneNote z przepływu.

public Notebook(Stream stream)

Parameters

stream Stream

w strumieniu .

Notebook(Strumień, NotebookLoadOptions)

Inicjalizuje nową instancję klasy Aspose.Note.Notebook.Otwiera istniejący notebook OneNote z przepływu. pozwala określić dodatkowe opcje ładowania.

public Notebook(Stream stream, NotebookLoadOptions loadOptions)

Parameters

stream Stream

w strumieniu .

loadOptions NotebookLoadOptions

Opcje opcji ładowania.

Properties

Color

Zostaw lub ustaw kolor.

public Color Color { get; set; }

Wartość nieruchomości

Color

Count

Otrzymuje liczbę elementów zawartych w Aspose.Note.Notebook.

public int Count { get; }

Wartość nieruchomości

int

DisplayName

Dostęp lub ustaw nazwę wyświetlacza.

public string DisplayName { get; set; }

Wartość nieruchomości

string

Examples

Pokaż, jak usunąć sekcję z notatki.

// 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

Dostęp do formatu pliku (OneNote 2010),

public FileFormat FileFormat { get; }

Wartość nieruchomości

FileFormat

Guid

Otrzymuje globalnie unikalny identyfikator obiektu.

public Guid Guid { get; }

Wartość nieruchomości

Guid

IsHistoryEnabled

Otrzymuje lub ustawia wartość wskazującą, czy historia jest włączona.

public bool IsHistoryEnabled { get; set; }

Wartość nieruchomości

bool

Tego[Int]

Otrzymuje notatkę dziecięce przez dany indeks.

public INotebookChildNode this[int index] { get; }

Wartość nieruchomości

INotebookChildNode

Methods

AppendChild(InnowacjaChildNode)

Dodaj przycisk do końca listy.

public INotebookChildNode AppendChild(INotebookChildNode newChild)

Parameters

newChild INotebookChildNode

Noda do dodania.

Returns

INotebookChildNode

Dodany wkładek.

Zwiastun T1>()

Zdobądź wszystkie węzły dziecka według typu węgla.

public IList<t1> GetChildNodes<t1>() where T1 : Node

Returns

IList

Lista węzłów dziecięcych.

Rodzaj parametrów

T1

Rodzaj elementów w zwróconej liście.

GetEnumerator()

Powraca numerator, który iteruje przez węzły dziecięce Aspose.Note.Notebook.

public IEnumerator<inotebookchildnode> GetEnumerator()

Returns

IEnumerator • < INotebookChildNode >

A System. Kolekcje.IEnumerator

LoadChildDocument(strumień)

Dodaj dziecku dokument node.Otwórz istniejący dokument OneNote z pliku.

public void LoadChildDocument(string filePath)

Parameters

filePath string

Droga do pliku.

Examples

Pokaż, jak pobierać notatkę 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(String, Opcje ładowania)

Dodaj dziecku dokument node.Otwiera istniejący dokument OneNote z pliku. pozwala określić dodatkowe opcje ładowania.

public void LoadChildDocument(string filePath, LoadOptions loadOptions)

Parameters

filePath string

Droga do pliku.

loadOptions LoadOptions

Opcje opcji ładowania.

LoadChildDocument(Stream)

Dodaj dziecku dokument node.Otwórz istniejący dokument OneNote z przepływu.

public void LoadChildDocument(Stream stream)

Parameters

stream Stream

w strumieniu .

Examples

Pokaż, jak pobierać notatkę 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(Strumień, LoadOptions)

Dodaj dziecku dokument node.Otwiera istniejący dokument programu OneNote z przepływu. pozwala określić dodatkowe opcje ładowania.

public void LoadChildDocument(Stream stream, LoadOptions loadOptions)

Parameters

stream Stream

w strumieniu .

loadOptions LoadOptions

Opcje opcji ładowania.

LoadChildNotebook(strumień)

Dodaj dziecku notatkę.Otwórz istniejący notebook OneNote z pliku.

public void LoadChildNotebook(string filePath)

Parameters

filePath string

Droga do pliku.

LoadChildNotebook(Tłumaczenia, NotebookLoadOptions)

Dodaj dziecku notatkę.Otwiera istniejący notebook OneNote z pliku. pozwala określić dodatkowe opcje ładowania.

public void LoadChildNotebook(string filePath, NotebookLoadOptions loadOptions)

Parameters

filePath string

Droga do pliku.

loadOptions NotebookLoadOptions

Opcje opcji ładowania.

LoadChildNotebook(Stream)

Dodaj dziecku notatkę.Otwórz istniejący notebook OneNote z przepływu.

public void LoadChildNotebook(Stream stream)

Parameters

stream Stream

w strumieniu .

LoadChildNotebook(Strumień, NotebookLoadOptions)

Dodaj dziecku notatkę.Otwiera istniejący notebook OneNote z przepływu. pozwala określić dodatkowe opcje ładowania.

public void LoadChildNotebook(Stream stream, NotebookLoadOptions loadOptions)

Parameters

stream Stream

w strumieniu .

loadOptions NotebookLoadOptions

Opcje opcji ładowania.

RemoveChild(InnowacjaChildNode)

Usunąć dziecko węzła.

public INotebookChildNode RemoveChild(INotebookChildNode oldChild)

Parameters

oldChild INotebookChildNode

Noda do usunięcia.

Returns

INotebookChildNode

Usunięte węzły .

Examples

Pokaż, jak uzyskać dostęp do wszystkich sekcji z notebooka.

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>

Pokaż, jak usunąć sekcję z notatki.

// 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>

Pokaż jak zaoszczędzić notatkę.

// 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(strumień)

Zapisz dokument OneNote do pliku.

public void Save(string fileName)

Parameters

fileName string

Pełna nazwa pliku.Jeśli plik z wyznaczonym pełnym nazwą już istnieje, istniejące pliki są przesłane.

Exceptions

IncorrectDocumentStructureException

Struktura dokumentu narusza specyfikację.

UnsupportedSaveFormatException

Zapytany format nie jest obsługiwany.

Save(Stream)

Zapisz dokument OneNote na strumień.

public void Save(Stream stream)

Parameters

stream Stream

w strumieniu .

Exceptions

IncorrectDocumentStructureException

Struktura dokumentu narusza specyfikację.

UnsupportedSaveFormatException

Zapytany format nie jest obsługiwany.

Save(strumień, SaveFormat)

Zapisz dokument OneNote do pliku w określonym formacie.

public void Save(string fileName, SaveFormat format)

Parameters

fileName string

Pełna nazwa pliku.Jeśli plik z wyznaczonym pełnym nazwą już istnieje, istniejące pliki są przesłane.

format SaveFormat

Format, w którym można zapisać dokument.

Exceptions

IncorrectDocumentStructureException

Struktura dokumentu narusza specyfikację.

UnsupportedSaveFormatException

Zapytany format nie jest obsługiwany.

Save(Strumień, SaveFormat)

Zapisz dokument OneNote do strumienia w określonym formacie.

public void Save(Stream stream, SaveFormat format)

Parameters

stream Stream

w strumieniu .

format SaveFormat

Format, w którym można zapisać dokument.

Exceptions

IncorrectDocumentStructureException

Struktura dokumentu narusza specyfikację.

UnsupportedSaveFormatException

Zapytany format nie jest obsługiwany.

Save(String, NotebookSaveOptions)

Zapisz dokument OneNote do pliku za pomocą określonych opcji zapisywania.

public void Save(string fileName, NotebookSaveOptions options)

Parameters

fileName string

Pełna nazwa pliku.Jeśli plik z wyznaczonym pełnym nazwą już istnieje, istniejące pliki są przesłane.

options NotebookSaveOptions

Określa opcje, w jaki sposób dokument jest zapisywany w pliku.

Exceptions

IncorrectDocumentStructureException

Struktura dokumentu narusza specyfikację.

UnsupportedSaveFormatException

Zapytany format nie jest obsługiwany.

Save(Strumień, NotebookSaveOptions)

Zapisz dokument OneNote do strumienia za pomocą określonych opcji zapisywania.

public void Save(Stream stream, NotebookSaveOptions options)

Parameters

stream Stream

w strumieniu .

options NotebookSaveOptions

Określa opcje, w jaki sposób dokument jest zapisywany.

Exceptions

IncorrectDocumentStructureException

Struktura dokumentu narusza specyfikację.

UnsupportedSaveFormatException

Zapytany format nie jest obsługiwany.

 Polski