| | |
| | | * @param output |
| | | * @return |
| | | */ |
| | | @Deprecated |
| | | public static File convertToPdf(String input, String output) throws Exception { |
| | | File inputFile = null; |
| | | File outFile = null; |
| | |
| | | } |
| | | return outFile; |
| | | } |
| | | /** |
| | | * 转换pdf |
| | | * @param input |
| | | * @param output |
| | | * @return |
| | | */ |
| | | public static File convertToPdf(String input, String output,String officeType) throws Exception { |
| | | File inputFile = null; |
| | | File outFile = null; |
| | | OfficeManager officeManager = null; |
| | | try { |
| | | if(Global.getPropertyToBoolean("open.office.isEnable", "true")) {//启用oepn office转换 |
| | | officeManager = officeManagerQueue.take(); |
| | | inputFile = new File(input); |
| | | outFile = new File(output); |
| | | SpringMVCContextHolder.getSystemLogger().info("开始转换文档:" + input + "=>" + output); |
| | | OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager); |
| | | converter.convert(inputFile, outFile); // 转换文档 |
| | | }else{ |
| | | outFile = new File(AsposeUtil.OfficeToPdf(input, output,officeType)); |
| | | } |
| | | |
| | | }catch (Exception e) { |
| | | outFile = null; |
| | | throw e; |
| | | } finally { |
| | | SpringMVCContextHolder.getSystemLogger().info("结束转换文档"); |
| | | if (officeManager != null) { |
| | | try { |
| | | officeManagerQueue.put(officeManager); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return outFile; |
| | | } |
| | | } |