许鹏程
2023-08-04 efdccbfcb1f20afba47e0abbd0f1319160d44df2
word 转pdf时不保留修订痕迹
已修改1个文件
28 ■■■■ 文件已修改
src/main/java/com/product/file/util/AsposeUtil.java 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/file/util/AsposeUtil.java
@@ -73,7 +73,7 @@
        return result;
    }
    /**
     *
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -109,7 +109,7 @@
        }
    }
    /**
     *
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -200,7 +200,7 @@
        }
    }
    /**
     *
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -218,6 +218,8 @@
            }
            Document doc = new Document(officePath);// 原始word路径
            fileOS = new FileOutputStream(OutPutPath);
            //不保留修订痕迹
            doc.acceptAllRevisions();
            doc.save(fileOS, com.aspose.words.SaveFormat.PDF);
        } catch (Exception e) {
            throw new BaseException(FileCode.DOC_CONVERT_FALL,e);
@@ -233,7 +235,7 @@
        }
    }
    /**
     *
     *
     * @param officePath
     * @param OutPutPath
     * @throws BaseException
@@ -357,7 +359,7 @@
     * @throws Exception
     */
    public static File mergeWord(File target,File source ) throws BaseException{
        if(!target.exists() && !source.exists()) {
            return null;
        }else if(!source.exists() && target.exists()) {
@@ -378,7 +380,7 @@
            tin=new FileInputStream(target);
            sin=new FileInputStream(source);
            Document targetDoc = new Document(tin);
            Document sourceDoc = new Document(sin);
            Document sourceDoc = new Document(sin);
//            docBlankProcess(targetDoc);
            targetDoc.appendDocument(sourceDoc, ImportFormatMode.KEEP_SOURCE_FORMATTING);
//            NodeCollection t =sourceDoc.getChildNodes();
@@ -418,7 +420,7 @@
        }
        return temp_target;
    }
    public static void docBlankProcess(Document targetDoc) {
        NodeCollection nodes=targetDoc.getChildNodes(NodeType.PARAGRAPH, true);
        System.out.println(nodes.getCount());
@@ -432,7 +434,7 @@
            else if("\f".equals(text))System.out.println("\\\\f");
            else if("".equals(text.trim())) System.out.println("空格");
            else System.out.println(text);
            NodeCollection pnodes =para.getChildNodes();
            if(pnodes.getCount()==0)para.appendChild(new Run(targetDoc,"a"));
            if(para.isEndOfSection())para.appendChild(new Run(targetDoc,"B"));
@@ -440,7 +442,7 @@
            for(int i=0;i<pnodes.getCount();i++) {
                Node d=pnodes.get(i);
                System.out.println("type:"+NodeType.getName(d.getNodeType()));
                if("\r".equals(text))System.out.println("\\\\r");
                else if("\f".equals(text))System.out.println("\\\\f");
                else if("".equals(text.trim())) System.out.println("空格");
@@ -452,13 +454,13 @@
                    ss.add(d);
                }
            }
        }
        for(Node d:ss) {
            d.remove();
        }
    }
    private static String appendDoc(String sohuyepath, String xuyepath, boolean includeSection) throws Exception {
@@ -566,7 +568,7 @@
//        String file="E:/采集提取日志表结构.xlsx";
        String file="E:/FE信息系统国产化解决方案V1.0.docx";
//        AsposeUtil.OfficeToPdf(file);
//        AsposeUtil.mergeWord("E:\\QQ\\住房担保置换公司.docx","E:\\QQ\\住房担保置换公司2.docx");
//        try {
//            processDocPage();