透过 Aspose.Words 操作 Word Document ,
要加入换行 或是段落要跟原本的文档一样高,
要如何处理呢?
透过 Aspose.Words 操作 Word Document,
要 Copy 某个区块中的 Tables 时,
因为每个 Table 中都有一个段落,
直接加入一个段落时,会发现默认加入的段落跟原本的不同,如下,
那要如何处理呢?
其实只要 Clone 各 Table 间的 段落再加入就可以了,如下的Code,var nextSibling = [原table].NextSibling;
if (nextSibling != null
&& nextSibling.NodeType == NodeType.Paragraph)
{
var pClone = [原table].NextSibling.Clone(true);
doc.InsertAfter(pClone, [那个对象之后]);
}
如果是要换页的话,就新增一个段落,然后加入换页就可以了,如下,var p = new Paragraph(doc);
Run pageBreakRun = new Run(doc, ControlChar.PageBreak);
p.AppendChild(pageBreakRun);
参考数据
Aspose.Words Document Object Model