当前位置: 首页>>代码示例>>C#>>正文


C# Document.JoinRunsWithSameFormatting方法代码示例

本文整理汇总了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);
        }
开发者ID:animaal,项目名称:Aspose_Words_NET,代码行数:29,代码来源:ExDocument.cs


注:本文中的Aspose.Words.Document.JoinRunsWithSameFormatting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。