Class TextStyle

Class TextStyle

Nome do espaço: Aspose.Note Assembleia: Aspose.Note.dll (25.4.0)

especifica o estilo de texto.

public sealed class TextStyle : Style

Inheritance

object Style TextStyle

Membros herdados

Style.GetHashCode() , Style.IsBold , Style.IsItalic , Style.IsUnderline , Style.IsStrikethrough , Style.IsSuperscript , Style.IsSubscript , Style.FontName , Style.FontSize , Style.FontColor , Style.Highlight , Style.FontStyle , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Vamos enfatizar os títulos da página entre outros cabeçalhos aumentando o tamanho da letra.

string dataDir = RunExamples.GetDataDir_Text();

                                                                                       // Load the document into Aspose.Note.
                                                                                       Document document = new Document(dataDir + "Aspose.one");

                                                                                       // Iterate through page's titles.
                                                                                       foreach (var title in document.Select(e => e.Title.TitleText))
                                                                                       {
                                                                                           title.ParagraphStyle.FontSize = 24;
                                                                                           title.ParagraphStyle.IsBold = true;

                                                                                           foreach (var run in title.TextRuns)
                                                                                           {
                                                                                               run.Style.FontSize = 24;
                                                                                               run.Style.IsBold = true;
                                                                                           }
                                                                                       }

                                                                                       document.Save(Path.Combine(dataDir, "ChangePageTitleStyle.pdf"));

Vamos enfatizar as mudanças mais recentes do texto, destacando.

string dataDir = RunExamples.GetDataDir_Text();

                                                                 // Load the document into Aspose.Note.
                                                                 Document document = new Document(dataDir + "Aspose.one");

                                                                 // Get RichText nodes modified last week.
                                                                 var richTextNodes = document.GetChildNodes<richtext>().Where(e =&gt; e.LastModifiedTime &gt;= DateTime.Today.Subtract(TimeSpan.FromDays(7)));

                                                                 foreach (var node in richTextNodes)
                                                                 {
                                                                     // Set highlight color
                                                                     node.ParagraphStyle.Highlight = Color.DarkGreen;
                                                                     foreach (var run in node.TextRuns)
                                                                     {
                                                                         // Set highlight color
                                                                         run.Style.Highlight = Color.DarkSeaGreen;
                                                                     }
                                                                 }

                                                                 document.Save(Path.Combine(dataDir, "HighlightAllRecentChanges.pdf"));</richtext>

Defina a linguagem de prova para um texto.

var document = new Document();
                                            var page = new Page();
                                            var outline = new Outline();
                                            var outlineElem = new OutlineElement();

                                            var text = new RichText() { ParagraphStyle = ParagraphStyle.Default };
                                            text.Append("United States", new TextStyle() { Language = CultureInfo.GetCultureInfo("en-US") })
                                                .Append(" Germany", new TextStyle() { Language = CultureInfo.GetCultureInfo("de-DE") })
                                                .Append(" China", new TextStyle() { Language = CultureInfo.GetCultureInfo("zh-CN") });

                                            outlineElem.AppendChildLast(text);
                                            outline.AppendChildLast(outlineElem);
                                            page.AppendChildLast(outline);
                                            document.AppendChildLast(page);

                                            document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetProofingLanguageForText.one"));

Manipular pelo formato de texto usando o estilo de parágrafo.

var document = new Document();
                                                           var page = new Page();
                                                           var outline = new Outline();
                                                           var outlineElem = new OutlineElement();

                                                           var text = new RichText() { ParagraphStyle = new ParagraphStyle() { FontName = "Courier New", FontSize = 20 } }
                                                                           .Append($"DefaultParagraphFontAndSize{Environment.NewLine}")
                                                                           .Append($"OnlyDefaultParagraphFont{Environment.NewLine}", new TextStyle() { FontSize = 14 })
                                                                           .Append("OnlyDefaultParagraphFontSize", new TextStyle() { FontName = "Verdana" });

                                                           outlineElem.AppendChildLast(text);
                                                           outline.AppendChildLast(outlineElem);
                                                           page.AppendChildLast(outline);
                                                           document.AppendChildLast(page);

                                                           document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetDefaultParagraphStyle.one"));

Mostra como ligar um hiperlink a um texto.

// The path to the documents directory.
                                                   string dataDir = RunExamples.GetDataDir_Tasks();

                                                   // Create an object of the Document class
                                                   Document doc = new Document();

                                                   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");

                                                   Outline outline = new Outline()
                                                                         {
                                                                             MaxWidth = 200,
                                                                             MaxHeight = 200,
                                                                             VerticalOffset = 100,
                                                                             HorizontalOffset = 100
                                                                         };

                                                   TextStyle textStyleRed = new TextStyle
                                                                                {
                                                                                    FontColor = Color.Red,
                                                                                    FontName = "Arial",
                                                                                    FontSize = 10,
                                                                                };

                                                   TextStyle textStyleHyperlink = new TextStyle
                                                                                      {
                                                                                          IsHyperlink = true,
                                                                                          HyperlinkAddress = "www.google.com"
                                                                                      };

                                                   RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
                                                                       .Append("This is ", textStyleRed)
                                                                       .Append("hyperlink", textStyleHyperlink)
                                                                       .Append(". This text is not a hyperlink.", TextStyle.Default);

                                                   OutlineElement outlineElem = new OutlineElement();
                                                   outlineElem.AppendChildLast(text);

                                                   // Add outline elements
                                                   outline.AppendChildLast(outlineElem);

                                                   // Initialize Title class object
                                                   Title title = new Title() { TitleText = titleText };

                                                   // Initialize Page class object
                                                   Page page = new Note.Page() { Title = title };

                                                   // Add Outline node
                                                   page.AppendChildLast(outline);

                                                   // Add Page node
                                                   doc.AppendChildLast(page);

                                                   // Save OneNote document
                                                   dataDir = dataDir + "AddHyperlink_out.one";
                                                   doc.Save(dataDir);

Constructors

TextStyle()

public TextStyle()

Properties

Default

É um estilo com a cultura “en-US”.

public static TextStyle Default { get; }

Valor da propriedade

TextStyle

DefaultMsOneNoteTitleDateStyle

Obtenha o estilo padrão para data de título em MS OneNote.

public static TextStyle DefaultMsOneNoteTitleDateStyle { get; }

Valor da propriedade

TextStyle

DefaultMsOneNoteTitleTextStyle

Obtenha estilo padrão para texto de título em MS OneNote.

public static TextStyle DefaultMsOneNoteTitleTextStyle { get; }

Valor da propriedade

TextStyle

DefaultMsOneNoteTitleTimeStyle

Obtenha estilo padrão para o tempo de título em MS OneNote.

public static TextStyle DefaultMsOneNoteTitleTimeStyle { get; }

Valor da propriedade

TextStyle

HyperlinkAddress

Deve ser definido se o valor da propriedade Aspose.Note.TextStyle.IsHyperlink é verdadeiro.

public string HyperlinkAddress { get; set; }

Valor da propriedade

string

Examples

Mostra como ligar um hiperlink a um texto.

// The path to the documents directory.
                                                   string dataDir = RunExamples.GetDataDir_Tasks();

                                                   // Create an object of the Document class
                                                   Document doc = new Document();

                                                   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");

                                                   Outline outline = new Outline()
                                                                         {
                                                                             MaxWidth = 200,
                                                                             MaxHeight = 200,
                                                                             VerticalOffset = 100,
                                                                             HorizontalOffset = 100
                                                                         };

                                                   TextStyle textStyleRed = new TextStyle
                                                                                {
                                                                                    FontColor = Color.Red,
                                                                                    FontName = "Arial",
                                                                                    FontSize = 10,
                                                                                };

                                                   TextStyle textStyleHyperlink = new TextStyle
                                                                                      {
                                                                                          IsHyperlink = true,
                                                                                          HyperlinkAddress = "www.google.com"
                                                                                      };

                                                   RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
                                                                       .Append("This is ", textStyleRed)
                                                                       .Append("hyperlink", textStyleHyperlink)
                                                                       .Append(". This text is not a hyperlink.", TextStyle.Default);

                                                   OutlineElement outlineElem = new OutlineElement();
                                                   outlineElem.AppendChildLast(text);

                                                   // Add outline elements
                                                   outline.AppendChildLast(outlineElem);

                                                   // Initialize Title class object
                                                   Title title = new Title() { TitleText = titleText };

                                                   // Initialize Page class object
                                                   Page page = new Note.Page() { Title = title };

                                                   // Add Outline node
                                                   page.AppendChildLast(outline);

                                                   // Add Page node
                                                   doc.AppendChildLast(page);

                                                   // Save OneNote document
                                                   dataDir = dataDir + "AddHyperlink_out.one";
                                                   doc.Save(dataDir);

IsHidden

Recebe ou coloca um valor indicando se o estilo de texto está escondido.

public bool IsHidden { get; set; }

Valor da propriedade

bool

IsHyperlink

Recebe ou coloca um valor indicando se o estilo de texto é hiperlink.

public bool IsHyperlink { get; set; }

Valor da propriedade

bool

Examples

Mostra como ligar um hiperlink a um texto.

// The path to the documents directory.
                                                   string dataDir = RunExamples.GetDataDir_Tasks();

                                                   // Create an object of the Document class
                                                   Document doc = new Document();

                                                   RichText titleText = new RichText() { ParagraphStyle = ParagraphStyle.Default }.Append("Title!");

                                                   Outline outline = new Outline()
                                                                         {
                                                                             MaxWidth = 200,
                                                                             MaxHeight = 200,
                                                                             VerticalOffset = 100,
                                                                             HorizontalOffset = 100
                                                                         };

                                                   TextStyle textStyleRed = new TextStyle
                                                                                {
                                                                                    FontColor = Color.Red,
                                                                                    FontName = "Arial",
                                                                                    FontSize = 10,
                                                                                };

                                                   TextStyle textStyleHyperlink = new TextStyle
                                                                                      {
                                                                                          IsHyperlink = true,
                                                                                          HyperlinkAddress = "www.google.com"
                                                                                      };

                                                   RichText text = new RichText() { ParagraphStyle = ParagraphStyle.Default }
                                                                       .Append("This is ", textStyleRed)
                                                                       .Append("hyperlink", textStyleHyperlink)
                                                                       .Append(". This text is not a hyperlink.", TextStyle.Default);

                                                   OutlineElement outlineElem = new OutlineElement();
                                                   outlineElem.AppendChildLast(text);

                                                   // Add outline elements
                                                   outline.AppendChildLast(outlineElem);

                                                   // Initialize Title class object
                                                   Title title = new Title() { TitleText = titleText };

                                                   // Initialize Page class object
                                                   Page page = new Note.Page() { Title = title };

                                                   // Add Outline node
                                                   page.AppendChildLast(outline);

                                                   // Add Page node
                                                   doc.AppendChildLast(page);

                                                   // Save OneNote document
                                                   dataDir = dataDir + "AddHyperlink_out.one";
                                                   doc.Save(dataDir);

IsMathFormatting

Recebe ou coloca um valor indicando se o estilo de texto é matemático.

public bool IsMathFormatting { get; set; }

Valor da propriedade

bool

Language

Obter ou definir a linguagem do texto.

public CultureInfo Language { get; set; }

Valor da propriedade

CultureInfo

Examples

Defina a linguagem de prova para um texto.

var document = new Document();
                                            var page = new Page();
                                            var outline = new Outline();
                                            var outlineElem = new OutlineElement();

                                            var text = new RichText() { ParagraphStyle = ParagraphStyle.Default };
                                            text.Append("United States", new TextStyle() { Language = CultureInfo.GetCultureInfo("en-US") })
                                                .Append(" Germany", new TextStyle() { Language = CultureInfo.GetCultureInfo("de-DE") })
                                                .Append(" China", new TextStyle() { Language = CultureInfo.GetCultureInfo("zh-CN") });

                                            outlineElem.AppendChildLast(text);
                                            outline.AppendChildLast(outlineElem);
                                            page.AppendChildLast(outline);
                                            document.AppendChildLast(page);

                                            document.Save(Path.Combine(RunExamples.GetDataDir_Text(), "SetProofingLanguageForText.one"));

Remarks

Retorna System.Globalization.CultureInfo.InvariantCultura se a propriedade não for definida.

Methods

Equals(Objeto)

Determina se o objeto especificado é igual ao objeto atual.

public override bool Equals(object obj)

Parameters

obj object

O objeto .

Returns

bool

É o sistema.Boolean.

Equals(TextStyle)

Determina se o objeto especificado é igual ao objeto atual.

public bool Equals(TextStyle other)

Parameters

other TextStyle

O objeto .

Returns

bool

É o sistema.Boolean.

GetHashCode()

Ele serve como uma função de hash para o tipo.

public override int GetHashCode()

Returns

int

O sistema.Int32.

 Português