本文整理汇总了C#中Aspose.Words.Document.JoinRunsWithSameFormatting方法的典型用法代码示例。如果您正苦于以下问题:C# Document.JoinRunsWithSameFormatting方法的具体用法?C# Document.JoinRunsWithSameFormatting怎么用?C# Document.JoinRunsWithSameFormatting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Aspose.Words.Document
的用法示例。
在下文中一共展示了Document.JoinRunsWithSameFormatting方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JoinRunsWithSameFormatting
public void JoinRunsWithSameFormatting()
{
//ExStart
//ExFor:Document.JoinRunsWithSameFormatting
//ExSummary:Shows how to join runs in a document to reduce unneeded runs.
// Let's load this particular document. It contains a lot of content that has been edited many times.
// This means the document will most likely contain a large number of runs with duplicate formatting.
Aspose.Words.Document doc = new Aspose.Words.Document(MyDir + "Rendering.doc");
// This is for illustration purposes only, remember how many run nodes we had in the original document.
int runsBefore = doc.GetChildNodes(NodeType.Run, true).Count;
// Join runs with the same formatting. This is useful to speed up processing and may also reduce redundant
// tags when exporting to HTML which will reduce the output file size.
int joinCount = doc.JoinRunsWithSameFormatting();
// This is for illustration purposes only, see how many runs are left after joining.
int runsAfter = doc.GetChildNodes(NodeType.Run, true).Count;
Console.WriteLine("Number of runs before:{0}, after:{1}, joined:{2}", runsBefore, runsAfter, joinCount);
// Save the optimized document to disk.
doc.Save(MyDir + "Document.JoinRunsWithSameFormatting Out.html");
//ExEnd
// Verify that runs were joined in the document.
Assert.Less(runsAfter, runsBefore);
Assert.AreNotEqual(0, joinCount);
}