From efdccbfcb1f20afba47e0abbd0f1319160d44df2 Mon Sep 17 00:00:00 2001
From: 许鹏程 <1821349743@qq.com>
Date: 星期五, 04 八月 2023 16:14:32 +0800
Subject: [PATCH] word 转pdf时不保留修订痕迹

---
 src/main/java/com/product/file/util/AsposeUtil.java |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/product/file/util/AsposeUtil.java b/src/main/java/com/product/file/util/AsposeUtil.java
index fff41cb..d584bae 100644
--- a/src/main/java/com/product/file/util/AsposeUtil.java
+++ b/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淇℃伅绯荤粺鍥戒骇鍖栬В鍐虫柟妗圴1.0.docx";
 //    	AsposeUtil.OfficeToPdf(file);
-    	
+
 //    	AsposeUtil.mergeWord("E:\\QQ\\浣忔埧鎷呬繚缃崲鍏徃.docx","E:\\QQ\\浣忔埧鎷呬繚缃崲鍏徃2.docx");
 //    	try {
 //    		processDocPage();

--
Gitblit v1.9.2