| | |
| | | return result; |
| | | } |
| | | /** |
| | | * |
| | | * |
| | | * @param officePath |
| | | * @param OutPutPath |
| | | * @throws BaseException |
| | |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * |
| | | * @param officePath |
| | | * @param OutPutPath |
| | | * @throws BaseException |
| | |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * |
| | | * @param officePath |
| | | * @param OutPutPath |
| | | * @throws BaseException |
| | |
| | | } |
| | | 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); |
| | |
| | | } |
| | | } |
| | | /** |
| | | * |
| | | * |
| | | * @param officePath |
| | | * @param OutPutPath |
| | | * @throws BaseException |
| | |
| | | * @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()) { |
| | |
| | | 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(); |
| | |
| | | } |
| | | return temp_target; |
| | | } |
| | | |
| | | |
| | | public static void docBlankProcess(Document targetDoc) { |
| | | NodeCollection nodes=targetDoc.getChildNodes(NodeType.PARAGRAPH, true); |
| | | System.out.println(nodes.getCount()); |
| | |
| | | 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")); |
| | |
| | | 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("空格"); |
| | |
| | | ss.add(d); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | for(Node d:ss) { |
| | | d.remove(); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | private static String appendDoc(String sohuyepath, String xuyepath, boolean includeSection) throws Exception { |
| | |
| | | // 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(); |