Class TextStyle
Il nome: Aspose.Note Assemblea: Aspose.Note.dll (25.4.0)
Determinare lo stile del testo.
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
I membri ereditari
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
Aggiungiamo i titoli della pagina tra gli altri titolo aumentando la dimensione della 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"));
Vogliamo sottolineare le ultime modifiche del testo con l’accento.
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"));
Configurare il linguaggio di prova per un testo.
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"));
Manipolare con il formato del testo utilizzando lo stile del paragrafo.
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 come collegare un collegamento a un testo.
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
Il testo ( )
public TextStyle()
{
}
Properties
Default
Ricevi lo stile con la cultura “in-US”.
public static TextStyle Default
{
get;
}
Valore di proprietà
DefaultMsOneNoteTitleDateStyle
Riceve lo stile predefinito per la data di titolo in MS OneNote.
public static TextStyle DefaultMsOneNoteTitleDateStyle
{
get;
}
Valore di proprietà
DefaultMsOneNoteTitleTextStyle
Riceve lo stile predefinito per il testo di titolo in MS OneNote.
public static TextStyle DefaultMsOneNoteTitleTextStyle
{
get;
}
Valore di proprietà
DefaultMsOneNoteTitleTimeStyle
Riceve lo stile predefinito per il tempo di titolo in MS OneNote.
public static TextStyle DefaultMsOneNoteTitleTimeStyle
{
get;
}
Valore di proprietà
HyperlinkAddress
È necessario impostare se il valore della proprietà Aspose.Note.TextStyle.IsHyperlink è vero.
public string HyperlinkAddress
{
get;
set;
}
Valore di proprietà
Examples
Mostra come collegare un collegamento a un testo.
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
Riceve o impone un valore che indica se lo stile di testo è nascosto.
public bool IsHidden
{
get;
set;
}
Valore di proprietà
IsHyperlink
Riceve o impone un valore che indica se lo stile di testo è un collegamento.
public bool IsHyperlink
{
get;
set;
}
Valore di proprietà
Examples
Mostra come collegare un collegamento a un testo.
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
Riceve o impone un valore che indica se lo stile di testo è formato matematico.
public bool IsMathFormatting
{
get;
set;
}
Valore di proprietà
Language
Riceve o impone il linguaggio del testo.
public CultureInfo language { get; set; }
Valore di proprietà
Examples
Configurare il linguaggio di prova per un testo.
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
Ritorna System.Globalization.CultureInfo.InvariantCultura se la proprietà non è impostata.
Methods
Gli oggetti (Object)
Determinare se l’oggetto specificato è uguale all’oggetto corrente.
public override bool Equals(object obj)
{
}
Parameters
obj
object
L’oggetto è
Returns
Il sistema.Boolean
Il testo (TextStyle)
Determinare se l’oggetto specificato è uguale all’oggetto corrente.
public bool Equals(TextStyle other)
{
return this.IsEqual(other);
}
Parameters
other
TextStyle
L’oggetto è
Returns
Il sistema.Boolean
Il codice ( )
Servisce come funzione hash per il tipo.
public override int GetHashCode()
{
}
Returns
Il sistema.Int32.