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
{
private Font _font;
private bool _isBold;
private bool _isItalic;
private int _baselineShift;
public bool IsBold
{
get { return _isBold; }
}
public int BaselineShift
{
get { return _baselineShift; }
}
private Font Font
{
get { return _font; }
set { _font = value; }
}
public bool IsItalic
{
get { return _isItalic; }
set { _isItalic = value; }
}
}
Inheritance
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();
Document document = new Document(dataDir + "Aspose.one");
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();
Document document = new Document(dataDir + "Aspose.one");
var richTextNodes = document.GetChildNodes<RichText>().Where(e => e.LastModifiedTime >= DateTime.Today.AddDays(-7));
foreach (var node in richTextNodes)
{
node.ParagraphStyle.Highlight = Color.DarkGreen;
foreach (var run in node.TextRuns)
{
run.Style.Highlight = Color.DarkSeaGreen;
}
}
document.Save(Path.Combine(dataDir, "HighlightAllRecentChanges.pdf"));
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.
string dataDir = RunExamples.GetDataDir_Tasks();
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);
outline.AppendChildLast(outlineElem);
Title title = new Title() { TitleText = titleText };
Note.Page page = new Note.Page() { Title = title };
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "AddHyperlink_out.one";
doc.Save(dataDir);
Constructors
Estilo de texto ( )
public TextStyle()
{
}
Properties
Default
É um estilo com a cultura “en-US”.
public static TextStyle Default
{
get;
}
Valor da propriedade
DefaultMsOneNoteTitleDateStyle
Obtenha o estilo padrão para data de título em MS OneNote.
public static TextStyle DefaultMsOneNoteTitleDateStyle
{
get;
}
Valor da propriedade
DefaultMsOneNoteTitleTextStyle
Obtenha estilo padrão para texto de título em MS OneNote.
public static TextStyle DefaultMsOneNoteTitleTextStyle
{
get;
}
Valor da propriedade
DefaultMsOneNoteTitleTimeStyle
Obtenha estilo padrão para o tempo de título em MS OneNote.
public static TextStyle DefaultMsOneNoteTitleTimeStyle
{
get;
}
Valor da propriedade
HyperlinkAddress
Deve ser definido se o valor da propriedade Aspose.Note.TextStyle.IsHyperlink é verdadeiro.
public string HyperlinkAddress
{
get;
set;
}
Valor da propriedade
Examples
Mostra como ligar um hiperlink a um texto.
string dataDir = RunExamples.GetDataDir_Tasks();
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);
outline.AppendChildLast(outlineElem);
Title title = new Title() { TitleText = titleText };
Note.Page page = new Note.Page() { Title = title };
page.AppendChildLast(outline);
doc.AppendChildLast(page);
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
IsHyperlink
Recebe ou coloca um valor indicando se o estilo de texto é hiperlink.
public bool IsHyperlink
{
get;
set;
}
Valor da propriedade
Examples
Mostra como ligar um hiperlink a um texto.
string dataDir = RunExamples.GetDataDir_Tasks();
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);
outline.AppendChildLast(outlineElem);
Title title = new Title() { TitleText = titleText };
Page page = new Note.Page() { Title = title };
page.AppendChildLast(outline);
doc.AppendChildLast(page);
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
Language
Obter ou definir a linguagem do texto.
public CultureInfo language { get; set; }
Valor da propriedade
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
Equalidade ( Objeto )
Determina se o objeto especificado é igual ao objeto atual.
public override bool Equals(object obj)
{
}
Parameters
obj
object
O objeto .
Returns
É o sistema.Boolean.
Equalidade (TextStyle)
Determina se o objeto especificado é igual ao objeto atual.
public bool Equals(TextStyle other)
{
return this.IsEqual(other);
}
Parameters
other
TextStyle
O objeto .
Returns
É o sistema.Boolean.
Conexão ( )
Ele serve como uma função de hash para o tipo.
public override int GetHashCode()
{
}
Returns
O sistema.Int32.