Class TextStyle
Nom dels espais: Aspose.Note Assemblea: Aspose.Note.dll (25.4.0)
Especifica l’estil de text.
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
Membres heretats
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
Enfatitzem els títols de la pàgina entre altres titulars augmentant la mida de font.
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"));
Enfatitzem els últims canvis del text mitjançant l’accent.
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"));
Establir el llenguatge de prova per a un text.
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 per format de text utilitzant l’estil del paràgraf.
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 com vincular un hiperenllaç a un text.
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
Estil de text()
public TextStyle()
{
}
Properties
Default
Aconsegueix l’estil amb la cultura “en-US”.
public static TextStyle Default
{
get;
}
Valor de la propietat
DefaultMsOneNoteTitleDateStyle
Obté l’estil de la data de títol en MS OneNote.
public static TextStyle DefaultMsOneNoteTitleDateStyle
{
get;
}
Valor de la propietat
DefaultMsOneNoteTitleTextStyle
Obté l’estil de text de títol en MS OneNote.
public static TextStyle DefaultMsOneNoteTitleTextStyle
{
get;
}
Valor de la propietat
DefaultMsOneNoteTitleTimeStyle
Obté l’estil de títol per al temps de titulació en MS OneNote.
public static TextStyle DefaultMsOneNoteTitleTimeStyle
{
get;
}
Valor de la propietat
HyperlinkAddress
S’ha d’establir si el valor de la propietat Aspose.Note.TextStyle.IsHyperlink és veritable.
public string HyperlinkAddress
{
get;
set;
}
Valor de la propietat
Examples
Mostra com vincular un hiperenllaç a un text.
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
Obté o estableix un valor que indiqui si l’estil de text està amagat.
public bool IsHidden
{
get;
set;
}
Valor de la propietat
IsHyperlink
Obté o estableix un valor que indiqui si l’estil de text és hiperenllaç.
public bool IsHyperlink
{
get;
set;
}
Valor de la propietat
Examples
Mostra com vincular un hiperenllaç a un text.
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
Obté o s’estableix un valor que indiqui si l’estil de text és format matemàtic.
public bool IsMathFormatting
{
get;
set;
}
Valor de la propietat
Language
Obtenir o establir el llenguatge del text.
public CultureInfo language { get; set; }
Valor de la propietat
Examples
Establir el llenguatge de prova per a un text.
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
Retorn Sistema.Globalització.CultureInfo.InvariantCultura si la propietat no està configurada.
Methods
Els objectes (objectes)
Determina si l’objecte especificat és igual a l’objecte actual.
public override bool Equals(object obj)
{
}
Parameters
obj
object
El seu objecte.
Returns
El sistema.Boolean
Estil de text (Text Style)
Determina si l’objecte especificat és igual a l’objecte actual.
public bool Equals(TextStyle other)
{
return this.IsEqual(other);
}
Parameters
other
TextStyle
El seu objecte.
Returns
El sistema.Boolean
Càlcul d’actuació ()
Serveix com una funció hash per al tipus.
public override int GetHashCode()
{
}
Returns
El sistema.Int32.