From c5b71cce5614ad22716efbf941a98688589ef65a Mon Sep 17 00:00:00 2001 From: shichongfu <shi_chongfu@163.com> Date: 星期五, 09 六月 2023 08:57:36 +0800 Subject: [PATCH] 打印转换 --- src/main/java/com/product/file/util/PdfConcurrenceUtil.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/product/file/util/PdfConcurrenceUtil.java b/src/main/java/com/product/file/util/PdfConcurrenceUtil.java index 784fc7c..80d0204 100644 --- a/src/main/java/com/product/file/util/PdfConcurrenceUtil.java +++ b/src/main/java/com/product/file/util/PdfConcurrenceUtil.java @@ -152,6 +152,7 @@ * @param output * @return */ + @Deprecated public static File convertToPdf(String input, String output) throws Exception { File inputFile = null; File outFile = null; @@ -178,4 +179,41 @@ } 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("寮�濮嬭浆鎹㈡枃妗o細" + 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; + } } -- Gitblit v1.9.2