Trabajando con estilos de texto

Cambie el color de la fuente, el tamaño y resalte todo el texto del nodo RichText

Este tema discute cambiar el color de la fuente, el tamaño y resaltar todo el texto de un nodo RichText. Esta característica proporciona un control más profundo de OneNote a los desarrolladores. Usando esta función, los desarrolladores pueden personalizar el color de fuente, el tamaño y el texto destacado de cualquier nodo de texto rico deseado.

Para cambiar la fuente y el color de un nodo de texto rico usando Aspose.note, siga los pasos a continuación:

  1. Cargue el documento OneNote en una clase documento.
  2. Acceda a un nodo RichText cuya fuente y colores deben cambiarse.
  3. Acceso a TextStyle.
  4. Establezca la fuente y el color del texto.
 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.