| | |
| | | package com.ots.project.tool; |
| | | import com.ots.common.utils.spring.SpringUtils; |
| | | import com.ots.common.utils.text.CharsetKit; |
| | | import com.ots.project.tool.libreoffice.Office2PDFUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.jodconverter.core.DocumentConverter; |
| | | import org.jodconverter.core.office.OfficeException; |
| | |
| | | @Component |
| | | public class ShellTool { |
| | | |
| | | // @Autowired |
| | | // private DocumentConverter documentConverter; |
| | | |
| | | @Autowired |
| | | private DocumentConverter documentConverter; |
| | | private Office2PDFUtils office2PDFUtils; |
| | | |
| | | private static ShellTool shellTool; |
| | | |
| | | @PostConstruct |
| | | public void init(){ |
| | | shellTool = this; |
| | | shellTool.documentConverter = documentConverter; |
| | | //shellTool.documentConverter = documentConverter; |
| | | shellTool.office2PDFUtils = office2PDFUtils; |
| | | } |
| | | |
| | | public static ShellTool builder(){ |
| | |
| | | |
| | | public static void execNewLibreofficeCommand(String type, String sourcePath, String targetPath) throws OfficeException { |
| | | //使用文件方式转换成PDF |
| | | shellTool.documentConverter.convert(new File(sourcePath)).to(new File(targetPath)).execute(); |
| | | //shellTool.documentConverter.convert(new File(sourcePath)).to(new File(targetPath)).execute(); |
| | | shellTool.office2PDFUtils.office2Pdf(sourcePath,targetPath); |
| | | } |
| | | |
| | | private static String exec(String command) { |