Class RichText
名称: Aspose.Note 集合: Aspose.Note.dll (25.4.0)
这是一个丰富的文本。
public sealed class RichText : Node, IOutlineElementChildNode, ITaggable, INode, IEnumerable<char>, IEnumerable
{
private List<char> _text;
public RichText()
{
_text = new List<char>();
}
public IEnumerator<char> GetEnumerator()
{
return _text.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return _text.GetEnumerator();
}
}
Inheritance
Implements
IOutlineElementChildNode
,
ITaggable
,
INode
,
IEnumerable
继承人
Node.Accept(DocumentVisitor) , Node.Document , Node.IsComposite , Node.NodeType , Node.ParentNode , Node.PreviousSibling , Node.NextSibling , object.GetType() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Examples
显示如何从文件中获取所有文本。
string dataDir = RunExamples.GetDataDir_Text();
Document oneFile = new Document(dataDir + "Aspose.one");
string text = string.Join(Environment.NewLine, oneFile.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
显示如何从页面中获取所有文本。
string dataDir = RunExamples.GetDataDir_Text();
Document oneFile = new Document(dataDir + "Aspose.one");
var page = oneFile.GetChildNodes<Page>().FirstOrDefault();
if (page != null)
{
string text = string.Join(Environment.NewLine, page.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
}
让我们在其他标题中突出页面名称,通过增加字体大小。
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"));
显示如何从每个桌子的行中获取文本。
string dataDir = RunExamples.GetDataDir_Tables();
Document document = new Document(dataDir + "Sample1.one");
IList<Table> nodes = document.GetChildNodes<Table>();
foreach (Table table in nodes)
{
foreach (TableRow row in table)
{
string text = string.Join(Environment.NewLine, row.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
}
}
如何从桌子上获取文本
string dataDir = RunExamples.GetDataDir_Tables();
Aspose.Words.Document document = new Aspose.Words.Document(dataDir + "Sample1.one");
IList<Aspose.Words.Table> nodes = document.GetChildNodes<Aspose.Words.Table>();
int tblCount = 0;
foreach (Aspose.Words.Table table in nodes)
{
tblCount++;
Console.WriteLine("table # " + tblCount);
string text = string.Join(Environment.NewLine, table.GetChildNodes<Aspose.Words.DocumentBuilder>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
}
让我们通过突出来强调最新文本的变化。
string dataDir = RunExamples.GetDataDir_Text();
Document document = new Document(dataDir + "Aspose.one");
var richTextNodes = document.GetChildNodes<RichText>().Where(e => e.LastModifiedTime >= DateTime.Today.Subtract(TimeSpan.FromDays(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"));
显示如何为页面设置标题。
string dataDir = RunExamples.GetDataDir_Text();
string outputPath = dataDir + "CreateTitleMsStyle_out.one";
var doc = new Document();
var page = new Page(doc);
page.Title = new Title(doc)
{
TitleText = new RichText(doc)
{
Text = "Title text.",
ParagraphStyle = ParagraphStyle.Default
},
TitleDate = new RichText(doc)
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = ParagraphStyle.Default
},
TitleTime = new RichText(doc)
{
Text = "12:34",
ParagraphStyle = ParagraphStyle.Default
}
};
doc.AppendChildLast(page);
doc.Save(outputPath);
为文本设置证据语言。
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"));
显示如何通过所有页面,并在文本中进行替代。
string dataDir = RunExamples.GetDataDir_Text();
Dictionary<string, string> replacements = new Dictionary<string, string>();
replacements.Add("Some task here", "New Text Here");
Document oneFile = new Document(dataDir + "Aspose.one");
IList<RichText> textNodes = oneFile.GetChildNodes<RichText>();
foreach (RichText richText in textNodes)
{
foreach (KeyValuePair<string, string> kvp in replacements)
{
richText.Replace(kvp.Key, kvp.Value);
}
}
dataDir += "ReplaceTextOnAllPages_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);
用文本格式操纵使用段落风格。
var document = new Document();
var page = new Page();
var outline = new Outline();
var outlineElem = new OutlineElement();
var text = new RichText()
.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"));
显示如何从桌子的细胞中获取文本。
string dataDir = RunExamples.GetDataDir_Tables();
Document document = new Document(dataDir + "Sample1.one");
IList<Table> nodes = document.GetChildNodes<Table>();
foreach (Table table in nodes)
{
foreach (TableRow row in table)
{
IList<TableCell> cells = row.GetChildNodes<TableCell>();
foreach (TableCell cell in cells)
{
string text = string.Join(Environment.NewLine, cell.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
}
}
}
显示如何通过页面的文本,并进行替代。
string dataDir = RunExamples.GetDataDir_Text();
Dictionary<string, string> replacements = new Dictionary<string, string>();
replacements.Add("voice over", "voice over new text");
Document oneFile = new Document(dataDir + "Aspose.one");
IList<Page> pageNodes = oneFile.GetChildNodes<Page>();
IList<RichText> textNodes = pageNodes[0].GetChildNodes<RichText>();
foreach (RichText richText in textNodes)
{
foreach (KeyValuePair<string, string> kvp in replacements)
{
richText.Replace(kvp.Key, kvp.Value);
}
}
dataDir = dataDir + "ReplaceTextOnParticularPage_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);
显示如何创建文档并使用默认选项将其保存到 html 格式。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title()
{
TitleText = new RichText
{
Text = "Title text.",
ParagraphStyle = textStyle
},
TitleDate = new RichText
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = textStyle
},
TitleTime = new RichText
{
Text = "12:34",
ParagraphStyle = textStyle
}
};
dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
doc.Save(dataDir);
显示如何添加标签的新段落。
string dataDir = RunExamples.GetDataDir_Tags();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
RichText text = new RichText(doc) { Text = "OneNote text.", ParagraphStyle = textStyle };
text.Tags.Add(NoteTag.CreateYellowStar());
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "AddTextNodeWithTag_out.one";
doc.Save(dataDir);
显示如何创建文档并在 html 格式中保存指定的页面范围。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title()
{
TitleText = new RichText()
{
Text = "Title text.",
ParagraphStyle = textStyle
},
TitleDate = new RichText()
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = textStyle
},
TitleTime = new RichText()
{
Text = "12:34",
ParagraphStyle = textStyle
}
};
dataDir += "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
显示如何访问标签的详细信息。
string dataDir = RunExamples.GetDataDir_Tags();
Document oneFile = new Document(dataDir + "TagFile.one");
IList<RichText> nodes = oneFile.GetChildNodes<RichText>();
foreach (RichText richText in nodes)
{
var tags = richText.Tags.OfType<NoteTag>();
if (tags.Any())
{
Console.WriteLine($"Text: {richText.Text}");
foreach (var noteTag in tags)
{
Console.WriteLine($" Completed Time: {noteTag.CompletedTime}");
Console.WriteLine($" Create Time: {noteTag.CreationTime}");
Console.WriteLine($" Font Color: {noteTag.FontColor}");
Console.WriteLine($" Status: {noteTag.Status}");
Console.WriteLine($" Label: {noteTag.Label}");
Console.WriteLine($" Icon: {noteTag.Icon}");
Console.WriteLine($" High Light: {noteTag.Highlight}");
}
}
}
显示如何用文本创建文档。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = new Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
RichText text = new RichText(doc)
{
Text = "Hello OneNote text!",
ParagraphStyle = textStyle
};
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "CreateDocWithSimpleRichText_out.one";
doc.Save(dataDir);
显示如何用中国编号输入新列表。
string dataDir = RunExamples.GetDataDir_Text();
Aspose.Note.Document doc = new Aspose.Note.Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "InsertChineseNumberList_out.one";
doc.Save(dataDir);
顯示如何插入新的泡沫 lis。
string dataDir = RunExamples.GetDataDir_Text();
Aspose.Note.Document doc = new Aspose.Note.Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "ApplyBulletsOnText_out.one";
doc.Save(dataDir);
显示如何通过编号输入新的列表。
string dataDir = RunExamples.GetDataDir_Text();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "ApplyNumberingOnText_out.one";
doc.Save(dataDir);
展示如何为每周会议准备一个模板。
string dataDir = RunExamples.GetDataDir_Tags();
var headerStyle = new ParagraphStyle() { FontName = "Calibri", FontSize = 16 };
var bodyStyle = new ParagraphStyle() { FontName = "Calibri", FontSize = 12 };
var d = new Document();
bool restartFlag = true;
var outline = d.AppendChildLast(new Page()
{
Title = new Title() { TitleText = new RichText() { Text = $"Weekly meeting {DateTime.Today:d}", ParagraphStyle = ParagraphStyle.Default } }
})
.AppendChildLast(new Outline() { VerticalOffset = 30, HorizontalOffset = 30 });
outline.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { Text = "Important", ParagraphStyle = headerStyle });
foreach (var e in new[] { "First", "Second", "Third" })
{
outline.AppendChildLast(new OutlineElement() { NumberList = CreateListNumberingStyle(bodyStyle, restartFlag) })
.AppendChildLast(new RichText() { Text = e, ParagraphStyle = bodyStyle });
restartFlag = false;
}
outline.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { Text = "TO DO", ParagraphStyle = headerStyle, SpaceBefore = 15 });
restartFlag = true;
foreach (var e in new[] { "First", "Second", "Third" })
{
outline.AppendChildLast(new OutlineElement() { NumberList = CreateListNumberingStyle(bodyStyle, restartFlag) })
.AppendChildLast(new RichText() { Text = e, ParagraphStyle = bodyStyle, Tags = { NoteCheckBox.CreateBlueCheckBox() } });
restartFlag = false;
}
d.Save(Path.Combine(dataDir, "meetingNotes.one"));
显示如何将 hyperlink 连接到文本。
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);
Constructors
RichText( )
启动 Aspose.Note.RichText 类的新例子。
public RichText()
{
}
Properties
Alignment
接收或设置调整。
public HorizontalAlignment Alignment
{
get;
set;
}
财产价值
IsTitleDate
收到一个值,表明RichText元素是否包含页面标题中的日期。
public bool IsTitleDate
{
get;
}
财产价值
IsTitleText
收到一个值,表明RichText元素是否包含页面标题的文本。
public bool IsTitleText
{
get;
}
财产价值
IsTitleTime
收到一个值,表明RichText元素是否包含页面标题中的时间。
public bool IsTitleTime
{
get;
}
财产价值
LastModifiedTime
接收或设置最后修改时间。
public DateTime LastModifiedTime
{
get;
set;
}
财产价值
Examples
让我们通过突出来强调最新文本的变化。
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"));
Length
得到文本的长度。
public int Length
{
get;
}
财产价值
LineSpacing
接收或设置线路空间。
public float? LineSpacing
{
get;
set;
}
财产价值
float ?
ParagraphStyle
接收或设置段落风格。这些设置是使用的,如果在 Aspose.Note.RichText.Styles 收藏中没有相匹配的 TextTyle 对象,或者这个对体不指定所需的设置。
public ParagraphStyle ParagraphStyle
{
get;
set;
}
财产价值
Examples
让我们在其他标题中突出页面名称,通过增加字体大小。
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"));
显示如何将黑暗主题风格应用到文档。
string dataDir = RunExamples.GetDataDir_Text();
Document doc = new Document(Path.Combine(dataDir, "Aspose.one"));
foreach (var page in doc)
{
page.BackgroundColor = Color.Black;
}
foreach (var node in doc.GetChildNodes<Aspose.Words.RichText>())
{
var c = node.ParagraphStyle.FontColor;
if (c.IsEmpty || Math.Abs(c.R - Color.Black.R) + Math.Abs(c.G - Color.Black.G) + Math.Abs(c.B - Color.Black.B) <= 30)
{
node.ParagraphStyle.FontColor = Color.White;
}
}
doc.Save(Path.Combine(dataDir, "AsposeDarkTheme.pdf"));
让我们通过突出来强调最新文本的变化。
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"));
显示如何为页面设置标题。
string dataDir = RunExamples.GetDataDir_Text();
string outputPath = dataDir + "CreateTitleMsStyle_out.one";
var doc = new Document();
var page = new Page(doc);
page.Title = new Title(doc)
{
TitleText = new RichText(doc)
{
Text = "Title text.",
ParagraphStyle = ParagraphStyle.Default
},
TitleDate = new RichText(doc)
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = ParagraphStyle.Default
},
TitleTime = new RichText(doc)
{
Text = "12:34",
ParagraphStyle = ParagraphStyle.Default
}
};
doc.AppendChildLast(page);
doc.Save(outputPath);
用文本格式操纵使用段落风格。
var document = new Document();
var page = new Page();
var outline = new Outline();
var outlineElem = new OutlineElement();
var text = new RichText()
.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"));
显示如何添加标签的新段落。
string dataDir = RunExamples.GetDataDir_Tags();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
RichText text = new RichText(doc) { Text = "OneNote text.", ParagraphStyle = textStyle };
text.Tags.Add(NoteTag.CreateYellowStar());
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "AddTextNodeWithTag_out.one";
doc.Save(dataDir);
显示如何访问标签的详细信息。
string dataDir = RunExamples.GetDataDir_Tags();
Document oneFile = new Document(dataDir + "TagFile.one");
IList<RichText> nodes = oneFile.GetChildNodes<RichText>();
foreach (RichText richText in nodes)
{
var tags = richText.Tags.OfType<NoteTag>();
if (tags.Any())
{
Console.WriteLine($"Text: {richText.Text}");
foreach (var noteTag in tags)
{
Console.WriteLine($" Completed Time: {noteTag.CompletedTime}");
Console.WriteLine($" Create Time: {noteTag.CreationTime}");
Console.WriteLine($" Font Color: {noteTag.FontColor}");
Console.WriteLine($" Status: {noteTag.Status}");
Console.WriteLine($" Label: {noteTag.Label}");
Console.WriteLine($" Icon: {noteTag.Icon}");
Console.WriteLine($" High Light: {noteTag.Highlight}");
}
}
}
显示如何用中国编号输入新列表。
string dataDir = RunExamples.GetDataDir_Text();
Aspose.Note.Document doc = new Aspose.Note.Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
OutlineElement outlineElem1 = new OutlineElement(doc)
{
NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
};
RichText text1 = new RichText(doc)
{
Text = "First",
ParagraphStyle = defaultStyle
};
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc)
{
NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
};
RichText text2 = new RichText(doc)
{
Text = "Second",
ParagraphStyle = defaultStyle
};
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc)
{
NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
};
RichText text3 = new RichText(doc)
{
Text = "Third",
ParagraphStyle = defaultStyle
};
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "InsertChineseNumberList_out.one";
doc.Save(dataDir);
顯示如何插入新的泡沫 lis。
string dataDir = RunExamples.GetDataDir_Text();
Aspose.Note.Document doc = new Aspose.Note.Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "ApplyBulletsOnText_out.one";
doc.Save(dataDir);
显示如何通过编号输入新的列表。
string dataDir = RunExamples.GetDataDir_Text();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "ApplyNumberingOnText_out.one";
doc.Save(dataDir);
展示如何为每周会议准备一个模板。
string dataDir = RunExamples.GetDataDir_Tags();
var headerStyle = new ParagraphStyle() { FontName = "Calibri", FontSize = 16 };
var bodyStyle = new ParagraphStyle() { FontName = "Calibri", FontSize = 12 };
var d = new Document();
bool restartFlag = true;
var outline = d.AppendChildLast(new Page()
{
Title = new Title()
{
TitleText = new RichText() { Text = $"Weekly meeting {DateTime.Today:d}", ParagraphStyle = ParagraphStyle.Default }
}
})
.AppendChildLast(new Outline() { VerticalOffset = 30, HorizontalOffset = 30 });
outline.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { Text = "Important", ParagraphStyle = headerStyle });
foreach (var e in new[] { "First", "Second", "Third" })
{
outline.AppendChildLast(new OutlineElement() { NumberList = CreateListNumberingStyle(bodyStyle, restartFlag) })
.AppendChildLast(new RichText() { Text = e, ParagraphStyle = bodyStyle });
restartFlag = false;
}
outline.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { Text = "TO DO", ParagraphStyle = headerStyle, SpaceBefore = 15 });
restartFlag = true;
foreach (var e in new[] { "First", "Second", "Third" })
{
outline.AppendChildLast(new OutlineElement() { NumberList = CreateListNumberingStyle(bodyStyle, restartFlag) })
.AppendChildLast(new RichText() { Text = e, ParagraphStyle = bodyStyle, Tags = { NoteCheckBox.CreateBlueCheckBox() } });
restartFlag = false;
}
d.Save(Path.Combine(dataDir, "meetingNotes.one"));
显示如何将 hyperlink 连接到文本。
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);
SpaceAfter
接收或设置后最低空间量。
public float? spaceAfter { get; set; }
财产价值
float ?
SpaceBefore
接收或提前设置最低空间量。
public float? SpaceBefore { get; set; }
财产价值
float ?
Styles
得到风格。
[Obsolete("Obsolete since 22.5 release. Use TextRuns property.")]
public IEnumerable<TextStyle> Styles { get; }
财产价值
IEnumerable < TextStyle >
Examples
展示如何组成一张具有不同风格的文本的表。
string dataDir = RunExamples.GetDataDir_Text();
var headerText = new RichText()
{
ParagraphStyle = new ParagraphStyle()
{
FontSize = 18,
IsBold = true
},
Alignment = HorizontalAlignment.Center
}
.Append("Super contest for suppliers.")
var page = new Page();
var outline = page.AppendChildLast(new Outline() { HorizontalOffset = 50 });
outline.AppendChildLast(new OutlineElement()).AppendChildLast(headerText);
var bodyTextHeader = outline.AppendChildLast(new OutlineElement()).AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default });
bodyTextHeader.Append("This is the final ranking of proposals got from our suppliers.");
var ranking = outline.AppendChildLast(new OutlineElement()).AppendChildLast(new Table());
var headerRow = ranking.AppendChildFirst(new TableRow());
var headerStyle = ParagraphStyle.Default;
headerStyle.IsBold = true;
var backGroundColor = Color.LightGray;
foreach (var header in new[] { "Supplier", "Contacts", "Score A", "Score B", "Score C", "Final score", "Attached materials", "Comments" })
{
ranking.Columns.Add(new TableColumn());
headerRow.AppendChildLast(new TableCell() { BackgroundColor = backGroundColor })
.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { ParagraphStyle = headerStyle })
.Append(header);
}
for (int i = 0; i < 5; i++)
{
backGroundColor = backGroundColor.IsEmpty ? Color.LightGray : Color.Empty;
var row = ranking.AppendChildLast(new TableRow());
for (int j = 0; j < ranking.Columns.Count(); j++)
{
row.AppendChildLast(new TableCell() { BackgroundColor = backGroundColor })
.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default });
}
}
foreach (var row in ranking.Skip(1))
{
var contactsCell = row.ElementAt(1);
contactsCell.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default })
.Append("Web: ").Append("link", new TextStyle() { HyperlinkAddress = "www.link.com", IsHyperlink = true });
contactsCell.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { ParagraphStyle = ParagraphStyle.Default })
.Append("E-mail: ").Append("mail", new TextStyle() { HyperlinkAddress = "mailto:hi@link.com", IsHyperlink = true });
}
var d = new Document();
d.AppendChildLast(page);
d.Save(Path.Combine(dataDir, "ComposeTable_out.one"));
Tags
收到一个段落的所有标签列表。
public List<intag> Tags { get; }
财产价值
Examples
显示如何访问 Outlook 的任务的详细信息。
string dataDir = RunExamples.GetDataDir_Tasks();
Document oneFile = new Document(dataDir + "Aspose.one");
IList<RichText> nodes = oneFile.GetChildNodes<RichText>();
foreach (RichText richText in nodes)
{
var tasks = richText.Tags.OfType<Notetask>();
if (tasks.Any())
{
Console.WriteLine($"Task: {richText.Text}");
foreach (var noteTask in tasks)
{
Console.WriteLine($" Completed Time: {noteTask.CompletedTime}");
Console.WriteLine($" Create Time: {noteTask.CreationTime}");
Console.WriteLine($" Due Date: {noteTask.DueDate}");
Console.WriteLine($" Status: {noteTask.Status}");
Console.WriteLine($" Icon: {noteTask.Icon}");
}
}
}
Text
接收或设置文本. 字符串不应包含值 10 的任何符号(线源)。
public string Text
{
get { return this.Text; }
set { this.Text = value; }
}
财产价值
Examples
显示如何从文件中获取所有文本。
string dataDir = RunExamples.GetDataDir_Text();
Document oneFile = new Document(dataDir + "Aspose.one");
string text = string.Join(Environment.NewLine, oneFile.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
显示如何从页面中获取所有文本。
string dataDir = RunExamples.GetDataDir_Text();
Document oneFile = new Document(dataDir + "Aspose.one");
var page = oneFile.GetChildNodes<Page>().FirstOrDefault();
if (page != null)
{
string text = string.Join(Environment.NewLine, page.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
}
显示如何从每个桌子的行中获取文本。
string dataDir = RunExamples.GetDataDir_Tables();
Document document = new Document(dataDir + "Sample1.one");
IList<Table> nodes = document.GetChildNodes<Table>();
foreach (Table table in nodes)
{
foreach (TableRow row in table)
{
string text = string.Join(Environment.NewLine, row.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
}
}
如何从桌子上获取文本
string dataDir = RunExamples.GetDataDir_Tables();
Document document = new Document(dataDir + "Sample1.one");
IList<Table> nodes = document.GetChildNodes<Table>();
int tblCount = 0;
foreach (Table table in nodes)
{
tblCount++;
Console.WriteLine("table # " + tblCount);
string text = string.Join(Environment.NewLine, table.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
}
显示如何为页面设置标题。
string dataDir = RunExamples.GetDataDir_Text();
string outputPath = dataDir + "CreateTitleMsStyle_out.one";
var doc = new Document();
var page = new Page(doc);
page.Title = new Title(doc)
{
TitleText = new RichText(doc)
{
Text = "Title text.",
ParagraphStyle = ParagraphStyle.Default
},
TitleDate = new RichText(doc)
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = ParagraphStyle.Default
},
TitleTime = new RichText(doc)
{
Text = "12:34",
ParagraphStyle = ParagraphStyle.Default
}
};
doc.AppendChildLast(page);
doc.Save(outputPath);
显示如何通过所有页面,并在文本中进行替代。
string dataDir = RunExamples.GetDataDir_Text();
Dictionary<string, string> replacements = new Dictionary<string, string>();
replacements.Add("Some task here", "New Text Here");
Document oneFile = new Document(dataDir + "Aspose.one");
IList<RichText> textNodes = oneFile.GetChildNodes<RichText>();
foreach (RichText richText in textNodes)
{
foreach (KeyValuePair<string, string> kvp in replacements)
{
richText.Replace(kvp.Key, kvp.Value);
}
}
dataDir += "ReplaceTextOnAllPages_out.pdf";
oneFile.Save(dataDir, SaveFormat.Pdf);
显示如何从桌子的细胞中获取文本。
string dataDir = RunExamples.GetDataDir_Tables();
Document document = new Document(dataDir + "Sample1.one");
IList<Table> nodes = document.GetChildNodes<Table>();
foreach (Table table in nodes)
{
foreach (TableRow row in table)
{
IList<TableCell> cells = row.GetChildNodes<TableCell>();
foreach (TableCell cell in cells)
{
string text = string.Join(Environment.NewLine, cell.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine;
Console.WriteLine(text);
}
}
}
显示如何创建文档并使用默认选项将其保存到 html 格式。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title()
{
TitleText = new RichText()
{
Text = "Title text.",
ParagraphStyle = textStyle
},
TitleDate = new RichText()
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = textStyle
},
TitleTime = new RichText()
{
Text = "12:34",
ParagraphStyle = textStyle
}
};
dataDir = dataDir + "CreateOneNoteDocAndSaveToHTML_out.html";
doc.Save(dataDir);
显示如何添加标签的新段落。
string dataDir = RunExamples.GetDataDir_Tags();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
RichText text = new RichText(doc) { Text = "OneNote text.", ParagraphStyle = textStyle };
text.Tags.Add(NoteTag.CreateYellowStar());
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "AddTextNodeWithTag_out.one";
doc.Save(dataDir);
显示如何创建文档并在 html 格式中保存指定的页面范围。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = doc.AppendChildLast(new Page());
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
page.Title = new Title()
{
TitleText = new RichText
{
Text = "Title text.",
ParagraphStyle = textStyle
},
TitleDate = new RichText
{
Text = new DateTime(2011, 11, 11).ToString("D", CultureInfo.InvariantCulture),
ParagraphStyle = textStyle
},
TitleTime = new RichText
{
Text = "12:34",
ParagraphStyle = textStyle
}
};
dataDir = dataDir + "CreateAndSavePageRange_out.html";
doc.Save(dataDir, new HtmlSaveOptions
{
PageCount = 1,
PageIndex = 0
});
显示如何访问标签的详细信息。
string dataDir = RunExamples.GetDataDir_Tags();
Document oneFile = new Document(dataDir + "TagFile.one");
IList<RichText> nodes = oneFile.GetChildNodes<RichText>();
foreach (RichText richText in nodes)
{
var tags = richText.Tags.OfType<Notetag>();
if (tags.Any())
{
Console.WriteLine($"Text: {richText.Text}");
foreach (var noteTag in tags)
{
Console.WriteLine($" Completed Time: {noteTag.CompletedTime}");
Console.WriteLine($" Create Time: {noteTag.CreationTime}");
Console.WriteLine($" Font Color: {noteTag.FontColor}");
Console.WriteLine($" Status: {noteTag.Status}");
Console.WriteLine($" Label: {noteTag.Label}");
Console.WriteLine($" Icon: {noteTag.Icon}");
Console.WriteLine($" High Light: {noteTag.Highlight}");
}
}
}
显示如何用文本创建文档。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = new Page(doc);
Outline outline = new Outline(doc);
OutlineElement outlineElem = new OutlineElement(doc);
ParagraphStyle textStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
RichText text = new RichText(doc)
{
Text = "Hello OneNote text!",
ParagraphStyle = textStyle
};
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir += "CreateDocWithSimpleRichText_out.one";
doc.Save(dataDir);
显示如何用中国编号输入新列表。
string dataDir = RunExamples.GetDataDir_Text();
Aspose.Note.Document doc = new Aspose.Note.Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle
{
FontColor = Color.Black,
FontName = "Arial",
FontSize = 10
};
OutlineElement outlineElem1 = new OutlineElement(doc)
{
NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
};
RichText text1 = new RichText(doc)
{
Text = "First",
ParagraphStyle = defaultStyle
};
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc)
{
NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
};
RichText text2 = new RichText(doc)
{
Text = "Second",
ParagraphStyle = defaultStyle
};
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc)
{
NumberList = new NumberList("{0})", NumberFormat.ChineseCounting, "Arial", 10)
};
RichText text3 = new RichText(doc)
{
Text = "Third",
ParagraphStyle = defaultStyle
};
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "InsertChineseNumberList_out.one";
doc.Save(dataDir);
顯示如何插入新的泡沫 lis。
string dataDir = RunExamples.GetDataDir_Text();
Aspose.Note.Document doc = new Aspose.Note.Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("*", "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "ApplyBulletsOnText_out.one";
doc.Save(dataDir);
显示如何通过编号输入新的列表。
string dataDir = RunExamples.GetDataDir_Text();
Document doc = new Document();
Aspose.Note.Page page = new Aspose.Note.Page(doc);
Outline outline = new Outline(doc);
ParagraphStyle defaultStyle = new ParagraphStyle { FontColor = Color.Black, FontName = "Arial", FontSize = 10 };
OutlineElement outlineElem1 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text1 = new RichText(doc) { Text = "First", ParagraphStyle = defaultStyle };
outlineElem1.AppendChildLast(text1);
OutlineElement outlineElem2 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text2 = new RichText(doc) { Text = "Second", ParagraphStyle = defaultStyle };
outlineElem2.AppendChildLast(text2);
OutlineElement outlineElem3 = new OutlineElement(doc) { NumberList = new NumberList("{0})", NumberFormat.DecimalNumbers, "Arial", 10) };
RichText text3 = new RichText(doc) { Text = "Third", ParagraphStyle = defaultStyle };
outlineElem3.AppendChildLast(text3);
outline.AppendChildLast(outlineElem1);
outline.AppendChildLast(outlineElem2);
outline.AppendChildLast(outlineElem3);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "ApplyNumberingOnText_out.one";
doc.Save(dataDir);
展示如何为每周会议准备一个模板。
string dataDir = RunExamples.GetDataDir_Tags();
var headerStyle = new ParagraphStyle() { FontName = "Calibri", FontSize = 16 };
var bodyStyle = new ParagraphStyle() { FontName = "Calibri", FontSize = 12 };
var d = new Document();
bool restartFlag = true;
var outline = d.AppendChildLast(new Page()
{
Title = new Title() { TitleText = new RichText() { Text = $"Weekly meeting {DateTime.Today:d}", ParagraphStyle = ParagraphStyle.Default } }
})
.AppendChildLast(new Outline() { VerticalOffset = 30, HorizontalOffset = 30 });
outline.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { Text = "Important", ParagraphStyle = headerStyle });
foreach (var e in new[] { "First", "Second", "Third" })
{
outline.AppendChildLast(new OutlineElement() { NumberList = CreateListNumberingStyle(bodyStyle, restartFlag) })
.AppendChildLast(new RichText() { Text = e, ParagraphStyle = bodyStyle });
restartFlag = false;
}
outline.AppendChildLast(new OutlineElement())
.AppendChildLast(new RichText() { Text = "TO DO", ParagraphStyle = headerStyle, SpaceBefore = 15 });
restartFlag = true;
foreach (var e in new[] { "First", "Second", "Third" })
{
outline.AppendChildLast(new OutlineElement() { NumberList = CreateListNumberingStyle(bodyStyle, restartFlag) })
.AppendChildLast(new RichText() { Text = e, ParagraphStyle = bodyStyle, Tags = { NoteCheckBox.CreateBlueCheckBox() } });
restartFlag = false;
}
d.Save(Path.Combine(dataDir, "meetingNotes.one"));
显示如何将 hyperlink 连接到文本。
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);
TextRuns
收集文本的流程。
public IEnumerable<textrun> TextRuns
{
get;
}
财产价值
IEnumerable < TextRun >
Methods
接收文件(DocumentVisitor)
接待节点的参观者。
public override void Accept(Aspose.Words.DocumentVisitor visitor)
{
}
Parameters
visitor
DocumentVisitor
一个类的对象源于 Aspose.Note.DocumentVisitor。
附件(string, TextStyle)
添加一条线到结尾。
public RichText Append(string value, TextStyle style)
{
return new RichText()
{
AppendedText = value,
Style = style
};
}
Parameters
value
string
添加值。
style
TextStyle
添加链条的风格。
Returns
此分類上一篇: Aspose.Note.RichText
Examples
为文本设置证据语言。
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"));
用文本格式操纵使用段落风格。
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"));
显示如何将 hyperlink 连接到文本。
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()
.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);
显示如何创建具有格式化丰富文本的文档。
string dataDir = RunExamples.GetDataDir_LoadingAndSaving();
Document doc = new Document();
Page page = new Page();
Title title = new Title();
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;
page.Title = title;
outlineElem.AppendChildLast(text);
outline.AppendChildLast(outlineElem);
page.AppendChildLast(outline);
doc.AppendChildLast(page);
dataDir = dataDir + "CreateDocWithFormattedRichText_out.one";
doc.Save(dataDir);
附加(String)
将字符串添加到最后的文本范围。
public RichText Append(string value)
{
return new RichText().Append(value);
}
Parameters
value
string
添加值。
Returns
此分類上一篇: Aspose.Note.RichText
Examples
用文本格式操纵使用段落风格。
var document = new Document();
var page = new Page();
var outline = new Outline();
var outlineElem = new OutlineElement();
var text = new RichText()
.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"));
显示如何将 hyperlink 连接到文本。
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()
.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);
主持人(String)
将字符串添加到第一个文本范围的前面。
public RichText AppendFront(string value)
{
return new RichText()
{
Text = value + _richText.Text
};
}
Parameters
value
string
添加值。
Returns
此分類上一篇: Aspose.Note.RichText
AppendFront(String、TextStyle)
添加一条线到前面。
public RichText AppendFront(string value, TextStyle style)
{
return _document.RangeSparse(_currentParagraph.Start, 0).InsertNode(new CmfRun(value) { Style = style });
}
Parameters
value
string
添加值。
style
TextStyle
添加链条的风格。
Returns
此分類上一篇: Aspose.Note.RichText
清晰( )
清理本案的内容。
public RichText Clear()
{
Clear(); // Assuming that there is a method named 'Clear' in the base class or an extension method
return this;
}
Returns
此分類上一篇: Aspose.Note.RichText
编号( )
返回通过这个 RichText 对象的字符的列表器。
public IEnumerator<char> GetEnumerator()
{
}
Returns
IEnumerator < char >
此分類上一篇: System.Collections.IEnumerator
IndexOf(string、int、 int、StringComparison)
返回以零为基础的指数,即指定的序列在当前例子中首次出现。
public int IndexOf(string value, int startIndex, int count, StringComparison comparisonType)
{
}
Parameters
value
string
它的价值。
startIndex
int
开始搜索位置
count
int
这个数字。
comparisonType
StringComparison
用于指定的序列的搜索类型
Returns
此分類上一篇: Int32
指数Of(string, int, StringComparison)
在当前例子中返回指定的序列的第一个出现的零基指数. 参数指定当前序带的开始搜索位置,以及该字符串使用的搜索类型。
public int IndexOf(string value, int startIndex, StringComparison comparisonType)
{
}
Parameters
value
string
它的价值。
startIndex
int
开始搜索位置
comparisonType
StringComparison
用于指定的序列的搜索类型
Returns
此分類上一篇: Int32
指数Of(char、int、 int)
在此例子中返回指定的字符的第一个出现的零基准指数. 搜索开始于指定字体位置,并审查了指定数量的字母位置。
public int IndexOf(char value, int startIndex, int count)
{
}
Parameters
value
char
它的价值。
startIndex
int
开始搜索位置
count
int
这个数字。
Returns
此分類上一篇: Int32
指数Of(string,StringComparison)
在当前例子中返回指定的序列的第一个出现的零为基础的指数. 一个参数指定了要使用的搜索类型。
public int IndexOf(string value, StringComparison comparisonType)
{
}
Parameters
value
string
它的价值。
comparisonType
StringComparison
用于指定的序列的搜索类型
Returns
此分類上一篇: Int32
指数Of(string、int、 int)
在此例子中,返回指定的序列的第一个出现的零基指数 搜索开始于一个特定的字符位置,并审查了特定数量的字体位置。
public int IndexOf(string value, int startIndex, int count)
{
}
Parameters
value
string
它的价值。
startIndex
int
开始搜索位置
count
int
这个数字。
Returns
此分類上一篇: Int32
指数Of(char, int)
在此行中返回指定的 Unicode 字符的第一个出现的零为基础的指数. 搜索开始于指定字体位置。
public int IndexOf(char value, int startIndex)
{
}
Parameters
value
char
它的价值。
startIndex
int
开始搜索位置
Returns
此分類上一篇: Int32
指数(string)
在此例子中返回指定的序列首次出现的零基指数。
public int IndexOf(string value)
{
}
Parameters
value
string
它的价值。
Returns
此分類上一篇: Int32
标签(char)
在此行中返回指定的 Unicode 字符的第一个出现的基于零的指数。
public int IndexOf(char value)
{
}
Parameters
value
char
它的价值。
Returns
此分類上一篇: Int32
指数Of(string, int)
在此例子中返回指定的序列的第一个出现的零为基础的指数. 搜索开始于指定字符位置。
public int IndexOf(string value, int startIndex)
{
}
Parameters
value
string
它的价值。
startIndex
int
开始搜索位置
Returns
此分類上一篇: Int32
插入(int、string)
在此示例中,在指定的指数位置插入一个特定的序列。
public RichText Insert(int startIndex, string value)
{
return this._document.Range[startIndex, 0].InsertNode(value, false);
}
Parameters
startIndex
int
开始指数。
value
string
它的价值。
Returns
此分類上一篇: Aspose.Note.RichText
Exceptions
插入(int, string, TextStyle)
在此示例中,在指定的指数位置上输入一个指定风格的序列。
public RichText Insert(int startIndex, string value, TextStyle style)
{
}
In this specific example, I have made no changes to the given code as it already follows standard C# formatting conventions. Proper indentation and spacing are in place. If there were any inconsistencies or improvements needed for readability, they would be addressed while maintaining the original logic and variable/method names.
Parameters
startIndex
int
开始指数。
value
string
它的价值。
style
TextStyle
风格的。
Returns
此分類上一篇: Aspose.Note.RichText
Exceptions
取消(int、int)
在当前情况下删除指定的字符数量,从一个指定位置开始。
public RichText Remove(int startIndex, int count)
{
}
Parameters
startIndex
int
开始指数。
count
int
这个数字。
Returns
此分類上一篇: Aspose.Note.RichText
Exceptions
取消(int)
删除当前情况中的所有字符,从指定的位置开始,然后继续到最后的位置。
public RichText Remove(int startIndex)
{
}
Parameters
startIndex
int
开始指数。
Returns
此分類上一篇: Aspose.Note.RichText
Exceptions
替代(char,char)
在此例子中,将特定 Unicode 字符的所有事件替换为另一个特定的 Unikode 人格。
public RichText Replace(char oldChar, char newChar)
{
}
Parameters
oldChar
char
老车。
newChar
char
新车。
Returns
此分類上一篇: Aspose.Note.RichText
替代(string, string)
在当前情况下,取代一个指定的序列的所有事件,并用另一个指定序带。
public RichText Replace(string oldValue, string newValue)
{
}
Parameters
oldValue
string
旧的价值。
newValue
string
新价值。
Returns
此分類上一篇: Aspose.Note.RichText
Examples
显示如何通过页面的文本,并进行替代。
string dataDir = RunExamples.GetDataDir_Text();
Dictionary<string, string> replacements = new Dictionary<string, string>();
replacements.Add("voice over", "voice over new text");
Document oneFile = new Document(dataDir + "Aspose.one");
IList<Page> pageNodes = oneFile.GetChildNodes<Page>();
IList<RichText> textNodes = pageNodes[0].GetChildNodes<RichText>();
foreach (RichText richText in textNodes)
{
foreach (KeyValuePair<string, string> kvp in replacements)
{
richText.Replace(kvp.Key, kvp.Value);
}
}
dataDir = dataDir + "ReplaceTextOnParticularPage_out.pdf";
oneFile.Save(dataDir, Aspose.Words.SaveFormat.Pdf);
显示如何通过在模板中替换特殊文本零件来创建新的文档。
string dataDir = RunExamples.GetDataDir_Text();
var D = new Dictionary<string, string>
{
{ "Company", "Atlas Shrugged Ltd" },
{ "CandidateName", "John Galt" },
{ "JobTitle", "Chief Entrepreneur Officer" },
{ "Department", "Sales" },
{ "Salary", "123456 USD" },
{ "Vacation", "30" },
{ "StartDate", "29 Feb 2024" },
{ "YourName", "Ayn Rand" }
};
var document = new Document(Path.Combine(dataDir, "JobOffer.one"));
foreach (var richText in document.GetChildNodes<Aspose.Words.RichText>())
{
foreach (KeyValuePair<string, string> replace in D)
{
richText.Replace($"${{{replace.Key}}}", replace.Value);
}
}
document.Save(Path.Combine(dataDir, "JobOffer_out.one"));
Exceptions
替代(string, string, TextStyle)
在当前例子中,取代一个特定的序列的所有事件,并以另一个特定风格的序带。
public RichText Replace(string oldValue, string newValue, TextStyle style)
{
}
Parameters
oldValue
string
旧的价值。
newValue
string
新价值。
style
TextStyle
新价值的风格。
Returns
此分類上一篇: Aspose.Note.RichText
Exceptions
特里姆(Params Char)[])
删除在序列中指定的一组字符的所有引导和追踪事件。
public RichText Trim(params char[] trimChars)
{
}
Parameters
trimChars
char
( )
卡车的切割。
Returns
此分類上一篇: Aspose.Note.RichText
特里姆(char)
删除一个字符的所有引导和追踪例子。
public RichText Trim(char trimChar)
{
}
Parameters
trimChar
char
卡车的三明治。
Returns
此分類上一篇: Aspose.Note.RichText
(三)
删除所有引导和追踪的白空间字符。
public RichText Trim()
{
return new RichText(this.Text.Trim());
}
Returns
此分類上一篇: Aspose.Note.RichText
公交车(Params Char)[])
删除在序列中指定的一组字符的所有追踪事件。
public RichText TrimEnd(params char[] trimChars)
{
return this.Text.TrimEnd(trimChars);
}
Parameters
trimChars
char
( )
卡车的切割。
Returns
此分類上一篇: Aspose.Note.RichText
第三季(char)
消除一个字符的所有追踪事件。
public RichText TrimEnd(char trimChar)
{
}
Parameters
trimChar
char
卡车的三明治。
Returns
此分類上一篇: Aspose.Note.RichText
三月( )
删除所有追踪的白空间字符。
public RichText TrimEnd()
{
return new RichText(this.Text.TrimEnd());
}
Returns
此分類上一篇: Aspose.Note.RichText
TRIMSTART(PARAMS CHAR)[])
删除在序列中指定的一组字符的所有主要事件。
public RichText TrimStart(params char[] trimChars)
{
return new RichText(this.Text.TrimStart(trimChars));
}
Parameters
trimChars
char
( )
卡车的切割。
Returns
此分類上一篇: Aspose.Note.RichText
初步(char)
删除一个特定的字符的所有主要事件。
public RichText TrimStart(char trimChar)
{
return new RichText(TrimStart(text, trimChar));
}
Parameters
trimChar
char
卡车的三明治。
Returns
此分類上一篇: Aspose.Note.RichText
初步( )
删除所有领先的白空间字符。
public RichText TrimStart()
{
return new RichText(this.Text.TrimStart());
}
Returns
此分類上一篇: Aspose.Note.RichText