| | |
| | | } |
| | | //线程同步 |
| | | if (threadSync) { |
| | | boolean b = convertPdf(uploadServer, isEncrypt, file, placeLocation, fileName); |
| | | boolean b = convertPdf(uploadServer, isEncrypt, file, placeLocation, fileName,tail); |
| | | if (deleteFile && file.isFile()) { |
| | | file.delete(); |
| | | } |
| | |
| | | String finalPlaceLocation = placeLocation; |
| | | final File ff = FileUtil.copyFile(file, Global.getSystemConfig("temp.dir", "") + "/" + "temp_convert_pdf_" + RandomUtil.randomString(5) + "_" + file.getName(), 0); |
| | | executorService.submit(() -> { |
| | | convertPdf(uploadServer, isEncrypt, ff, finalPlaceLocation, fileName); |
| | | convertPdf(uploadServer, isEncrypt, ff, finalPlaceLocation, fileName,tail); |
| | | if (ff.isFile()) { |
| | | ff.delete(); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | private static boolean convertPdf(boolean uploadServer, boolean isEncrypt, File file, String placeLocation, String fileName) throws BaseException { |
| | | private static boolean convertPdf(boolean uploadServer, boolean isEncrypt, File file, String placeLocation, String fileName,String officeType) throws BaseException { |
| | | File pdfFile = null; |
| | | String random = RandomUtil.randomString(5); |
| | | String tempPath = Global.getSystemConfig("temp.dir", "./attachment/temp") + "/" + "convertPDF_" + random + "_" + file.getName(); |
| | | String tempPathSuccess = Global.getSystemConfig("temp.dir", "./attachment/temp") + "/" + "convertPDF_success_" + random + ".pdf"; |
| | | try { |
| | | FileUtil.copyFile(file, tempPath, 0); |
| | | pdfFile = PdfConcurrenceUtil.convertToPdf(tempPath, tempPathSuccess); |
| | | pdfFile = PdfConcurrenceUtil.convertToPdf(tempPath, tempPathSuccess,officeType); |
| | | String s = Global.getSystemConfig("temp.dir", "") + "/" + "convertPDF_encryptTemp_" + random + ".pdf"; |
| | | FileUtil.copyFile(pdfFile, s, isEncrypt ? 1 : 0); |
| | | pdfFile.delete(); |
| | | pdfFile = new File(s); |
| | | uploadOtherFile(false, uploadServer, placeLocation, pdfFile, fileName); |
| | | return true; |
| | | } catch (Exception e) { |
| | | } |
| | | catch (BaseException e) { |
| | | throw e; |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new BaseException(FileCode.CONVERT_PDF_FILE_FAIL); |
| | | } finally { |
| | | try { |
| | | if (pdfFile.isFile()) { |
| | | if (pdfFile!=null && pdfFile.isFile()) { |
| | | pdfFile.delete(); |
| | | } |
| | | com.product.common.io.FileUtils.delFile(tempPath); |