lucika

aspose.words复制插入同一word文档中的某个页面

选择word模板

  Document doc = new Document(Server.MapPath("~\\templet") + "\\" + name.Name);
  doc.MailMerge.CleanupOptions = doc.MailMerge.CleanupOptions & ~MailMergeCleanupOptions.RemoveUnusedRegions;
  DocumentBuilder builder = new DocumentBuilder(doc);

插入页面

一句代码就可以搞定。

Aspose.Words.Document src;
doc.AppendDocument(src, ImportFormatMode.KeepSourceFormatting);

src是从word文档中选择的某一页的实例。

实例

将第一页添加数据重复显示。

Aspose.Words.Layout.LayoutCollector layoutCollector = new Aspose.Words.Layout.LayoutCollector(doc);
doc.UpdatePageLayout();
DocumentPageSplitter splitter = new DocumentPageSplitter(layoutCollector);
var a = splitter.GetDocumentOfPage(1);

最后,更新。

doc.UpdatePageLayout();

 

目前只实现了顺序插入页面的方法,也就是在文档最后添加新的页面,无法在特定页面插入新页面。比如,有4页,在第二页后插入新的页面。

选择特定页

有点麻烦。没有提供单独的API,但从官网的DEMO中可以找到改功能。DEMO中的PageSplitter实现了该功能。

或者下载

分类:

技术点:

相关文章:

  • 2022-01-13
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2022-12-23
  • 2021-12-22
猜你喜欢
  • 2021-11-22
  • 2022-01-02
  • 2021-12-05
  • 2021-06-19
  • 2022-12-23
  • 2021-12-20
相关资源
相似解决方案