RichText.Append
isi
[
bersembunyi
]Append(string, TextStyle)
Menambahkan string ke akhir.
public RichText Append(string value, TextStyle style)
Parameter | Jenis | Keterangan |
---|---|---|
value | String | Nilai tambah. |
style | TextStyle | Gaya string yang ditambahkan. |
Nilai Pengembalian
ItuRichText
.
Contoh
Atur bahasa pemeriksaan untuk teks.
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"));
Memanipulasi menurut format teks menggunakan gaya paragraf.
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"));
Menunjukkan cara mengikat hyperlink ke teks.
// Jalur ke direktori dokumen.
string dataDir = RunExamples.GetDataDir_Tasks();
// Buat objek dari kelas Dokumen
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);
// Tambahkan elemen kerangka
outline.AppendChildLast(outlineElem);
// Inisialisasi objek kelas Judul
Title title = new Title() { TitleText = titleText };
// Inisialisasi objek kelas Halaman
Page page = new Note.Page() { Title = title };
// Tambahkan simpul Outline
page.AppendChildLast(outline);
// Tambahkan simpul Halaman
doc.AppendChildLast(page);
// Simpan dokumen OneNote
dataDir = dataDir + "AddHyperlink_out.one";
doc.Save(dataDir);
Memperlihatkan cara membuat dokumen dengan teks kaya yang diformat.
// Jalur ke direktori dokumen.
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
// Buat objek dari kelas Dokumen
Document doc = new Document();
// Inisialisasi objek kelas Halaman
Page page = new Page();
// Inisialisasi objek kelas Judul
Title title = new Title();
// Inisialisasi objek kelas TextStyle dan atur properti pemformatan
ParagraphStyle defaultTextStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
RichText titleText = new RichText() { ParagraphStyle = defaultTextStyle }.Append("Title!");
Outline outline = new Outline()
{
VerticalOffset = 100,
HorizontalOffset = 100
};
OutlineElement outlineElem = new OutlineElement();
TextStyle textStyleForHelloWord = new TextStyle
{
FontColor = Color.Red,
FontName = "Arial",
FontSize = 10,
};
TextStyle textStyleForOneNoteWord = new TextStyle
{
FontColor = Color.Green,
FontName = "Calibri",
FontSize = 10,
IsItalic = true,
};
TextStyle textStyleForTextWord = new TextStyle
{
FontColor = Color.Blue,
FontName = "Arial",
FontSize = 15,
IsBold = true,
IsItalic = true,
};
RichText text = new RichText() { ParagraphStyle = defaultTextStyle }
.Append("Hello", textStyleForHelloWord)
.Append(" OneNote", textStyleForOneNoteWord)
.Append(" text", textStyleForTextWord)
.Append("!", TextStyle.Default);
title.TitleText = titleText;
// Tetapkan judul halaman
page.Title = title;
// Tambahkan simpul RichText
outlineElem.AppendChildLast(text);
// Tambahkan simpul OutlineElement
outline.AppendChildLast(outlineElem);
// Tambahkan simpul Outline
page.AppendChildLast(outline);
// Tambahkan simpul Halaman
doc.AppendChildLast(page);
// Simpan dokumen OneNote
dataDir = dataDir + "CreateDocWithFormattedRichText_out.one";
doc.Save(dataDir);
Lihat juga
- class TextStyle
- class RichText
- ruang nama Aspose.Note
- perakitan Aspose.Note
Append(string)
Menambahkan string ke rentang teks terakhir.
public RichText Append(string value)
Parameter | Jenis | Keterangan |
---|---|---|
value | String | Nilai tambah. |
Nilai Pengembalian
ItuRichText
.
Contoh
Memanipulasi menurut format teks menggunakan gaya paragraf.
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"));
Menunjukkan cara mengikat hyperlink ke teks.
// Jalur ke direktori dokumen.
string dataDir = RunExamples.GetDataDir_Tasks();
// Buat objek dari kelas Dokumen
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);
// Tambahkan elemen kerangka
outline.AppendChildLast(outlineElem);
// Inisialisasi objek kelas Judul
Title title = new Title() { TitleText = titleText };
// Inisialisasi objek kelas Halaman
Page page = new Note.Page() { Title = title };
// Tambahkan simpul Outline
page.AppendChildLast(outline);
// Tambahkan simpul Halaman
doc.AppendChildLast(page);
// Simpan dokumen OneNote
dataDir = dataDir + "AddHyperlink_out.one";
doc.Save(dataDir);
Lihat juga
- class RichText
- ruang nama Aspose.Note
- perakitan Aspose.Note