aspsoe 合并多个文档(保证每个文档的第一页在最新的一页)

  /**
     * 拼接多个word模板,每个模板分页
     * @param documentList
     * @return
     * @throws Exception
     */
    public static Document AddDocs2Doc(List<Document> documentList) throws Exception {
        if (documentList.size()>0){
            // 取第一个文档作为主文档,将其与的文档合并到它这里
            Document docAll = documentList.get(0);
            for (int i = 1; i < documentList.size(); i++) {
                Document doc = documentList.get(i);
                doc.getFirstSection().getPageSetup().setSectionStart(SectionStart.NEW_PAGE);
                docAll.appendDocument(doc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
            }
            return docAll;
        }
        return null;
    }

 

我理解,如果需要连续拼接的话,则将  SectionStart.NEW_PAGE 改为  SectionStart.CONTINUOUS 即可。

posted @ 2022-03-14 16:33  一去二三浪里小白龙  阅读(328)  评论(0编辑  收藏  举报
//增加一段JS脚本,为目录生成使用