選擇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實現了該功能。
或者下載