テキストスタイルを使用する

フォントの色、サイズを変更し、richtextノードのすべてのテキストを強調表示します

このトピックでは、フォントの色、サイズ、およびリッチテキストノードのすべてのテキストを強調表示することについて説明します。この機能は、開発者へのOneNoteのより詳細な制御を提供します。この機能を使用して、開発者はフォントの色、サイズ、および任意のリッチテキストノードのテキストを強調表示できます。

Aspose.Noteを使用して、リッチテキストノードのフォントと色を変更するには、以下の手順に従ってください。

  1. ドキュメントクラスにOneNoteドキュメントをロードします。 1.フォントと色を変更するリッチテキストノードにアクセスします。 1。テキストスタイルにアクセスします。 1.テキストのフォントと色を設定します。
 1string dataDir = RunExamples.GetDataDir_Text();
 2
 3// Load the document into Aspose.Note.
 4Document document = new Document(dataDir + "Aspose.one");
 5// Get a particular RichText node
 6IList<RichText> richTextNodes = document.GetChildNodes<RichText>();
 7RichText richText = richTextNodes[0];
 8
 9foreach (TextStyle style in richText.Styles)
10{
11    // Set font color
12    style.FontColor = Color.Yellow;
13    // Set highlight color
14    style.Highlight = Color.Blue;
15    // Set font size
16    style.FontSize = 20;
17}         

Set default paragraph style settings

Set proofing language for a text

Apply Dark mode style

The following code example demonstrates how to make OneNote document to look like in Dark mode.

 1// The path to the documents directory.
 2string dataDir = RunExamples.GetDataDir_Text();
 3
 4// Load the document into Aspose.Note.
 5Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
 6
 7foreach (var page in doc)
 8{
 9    page.BackgroundColor = Color.Black;
10}
11
12foreach (var node in doc.GetChildNodes<RichText>())
13{   
14    var c = node.ParagraphStyle.FontColor;
15    if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
16    {
17        node.ParagraphStyle.FontColor = Color.White;
18    }
19}
20
21doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.