[测评系统]--测评系统核心代码库
吴祝攀
2024-06-26 10b6c791f1a137ac97cce6844482649fc859309b
src/main/java/com/ots/project/tool/ShellTool.java
@@ -1,6 +1,7 @@
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;
@@ -15,14 +16,19 @@
@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(){
@@ -58,7 +64,8 @@
    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) {