Arbeiten mit Tags

Holen Sie sich Notiz -Tag -Details aus einem OneNote -Dokument

Die Notetag -Klasse bietet alle Eigenschaften, die sich auf ein Notiz -Tag in einem Microsoft OneNote -Dokument beziehen. Alle Notiz -Tags der OneNote -Datei sind durch Richtext -Knoten des Dokuments -Objekts enthalten. Das unten angegebene Code -Beispiel zeigt, wie Sie Details zu jedem Notiz -Tag von einem OneNote -Dokument abrufen.

 1// The path to the documents directory.
 2string dataDir = RunExamples.GetDataDir_Tags();
 3
 4// Load the document into Aspose.Note.
 5Document oneFile = new Document(dataDir + "TagFile.one");
 6
 7// Get all RichText nodes
 8IList<RichText> nodes = oneFile.GetChildNodes<RichText>();
 9
10// Iterate through each node
11foreach (RichText richText in nodes)
12{
13    foreach (var tag in richText.Tags)
14    {
15        if (tag is NoteTag)
16        {
17            NoteTag noteTag = (NoteTag)tag;
18            // Retrieve properties
19            Console.WriteLine("Completed Time: " + noteTag.CompletedTime);
20            Console.WriteLine("Create Time: " + noteTag.CreationTime);
21            Console.WriteLine("Font Color: " + noteTag.FontColor);
22            Console.WriteLine("Status: " + noteTag.Status);
23            Console.WriteLine("Label: " + noteTag.Label);
24            Console.WriteLine("Icon: " + noteTag.Icon);
25            Console.WriteLine("High Light: " + noteTag.Highlight);
26        }
27    }
28}

Tag wichtige Hinweise im OneNote -Dokument

Die Notetag -Klasse bietet alle Eigenschaften, die sich auf ein Notiz -Tag beziehen. Benutzer können jetzt Text, Bild und Tabellen mit einem Tag mit dem Tag mit dem Tag mit dem Tag mit dem Tag mit dem Tag mit dem Tag mit TEXT mit dem Tag mit dem Tag mit dem Tag mit TEXT MADIGEN. Aspose.Note FOR .NET APIS unterstützt alle diese Funktionsvorgänge.

Fügen Sie einen neuen Textknoten mit einem Tag hinzu

Das unten angegebene Codebeispiel zeigt, wie ein neuer Textknoten mit einem Tag im OneNote -Dokument hinzugefügt wird.

 1// The path to the documents directory.
 2string dataDir = RunExamples.GetDataDir_Tags();
 3
 4// Create an object of the Document class
 5Document doc = new Document();
 6// Initialize Page class object
 7Aspose.Note.Page page = new Aspose.Note.Page(doc);
 8// Initialize Outline class object
 9Outline outline = new Outline(doc);
10// Initialize OutlineElement class object
11OutlineElement outlineElem = new OutlineElement(doc);
12ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
13RichText text = new RichText(doc) { Text = "OneNote text.", ParagraphStyle = textStyle };
14text.Tags.Add(new NoteTag
15{
16    Icon = TagIcon.YellowStar,
17});
18
19// Add text node
20outlineElem.AppendChildLast(text);
21// Add outline element node
22outline.AppendChildLast(outlineElem);
23// Add outline node
24page.AppendChildLast(outline);
25// Add page node
26doc.AppendChildLast(page);
27
28dataDir = dataDir + "AddTextNodeWithTag_out.one";
29// Save OneNote document
30doc.Save(dataDir);

Fügen Sie einen neuen Bildknoten mit einem Tag hinzu

Das unten angegebene Code -Beispiel zeigt, wie ein neuer Bildknoten mit einem Tag im OneNote -Dokument hinzugefügt wird.

 1// The path to the documents directory.
 2string dataDir = RunExamples.GetDataDir_Tags();
 3
 4// Create an object of the Document class
 5Document doc = new Document();
 6// Initialize Page class object
 7Aspose.Note.Page page = new Aspose.Note.Page(doc);
 8// Initialize Outline class object
 9Outline outline = new Outline(doc);
10// Initialize OutlineElement class object
11OutlineElement outlineElem = new OutlineElement(doc);
12// Load an image
13Aspose.Note.Image image = new Aspose.Note.Image(doc, dataDir + "icon.jpg");
14// Insert image in the document node
15outlineElem.AppendChildLast(image);
16image.Tags.Add(new NoteTag
17{
18    Icon = TagIcon.YellowStar,
19});
20// Add outline element node
21outline.AppendChildLast(outlineElem);
22// Add outline node
23page.AppendChildLast(outline);
24// Add page node
25doc.AppendChildLast(page);
26
27dataDir = dataDir + "AddImageNodeWithTag_out.one";
28// Save OneNote document
29doc.Save(dataDir);

Fügen Sie einen neuen Tabellenknoten mit einem Tag hinzu

Das unten angegebene Codebeispiel zeigt, wie ein neuer Tabellenknoten mit einem Tag im OneNote -Dokument hinzugefügt wird.

 1// The path to the documents directory.
 2string dataDir = RunExamples.GetDataDir_Tags();
 3
 4// Create an object of the Document class
 5Document doc = new Document();
 6// Initialize Page class object
 7Aspose.Note.Page page = new Aspose.Note.Page(doc);
 8// Initialize TableRow class object
 9TableRow row = new TableRow(doc);
10// Initialize TableCell class object
11TableCell cell = new TableCell(doc);
12// Insert cell content
13cell.AppendChildLast(InsertTable.GetOutlineElementWithText(doc, "Single cell."));
14// Add cell to row node
15row.AppendChildLast(cell);
16// Initialize table node
17Table table = new Table(doc)
18{
19    IsBordersVisible = true,
20    Columns = { new TableColumn { Width = 70 } }
21};
22// Insert row node in table
23table.AppendChildLast(row);
24// Add tag to this table node
25table.Tags.Add(new NoteTag
26{
27    Icon = TagIcon.QuestionMark
28});
29
30Outline outline = new Outline(doc);
31OutlineElement outlineElem = new OutlineElement(doc);
32// Add table node
33outlineElem.AppendChildLast(table);
34// Add outline elements
35outline.AppendChildLast(outlineElem);
36page.AppendChildLast(outline);
37doc.AppendChildLast(page);
38
39dataDir = dataDir + "AddTableNodeWithTag_out.one";
40// Save OneNote document
41doc.Save(dataDir);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.